ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
python.atlas_oh.OHInputModule Class Reference
Inheritance diagram for python.atlas_oh.OHInputModule:
Collaboration diagram for python.atlas_oh.OHInputModule:

Public Member Functions

def __init__ (self)
 
None configure (self, Mapping[str, Any] options)
 
None setSelectors (self, Collection[Pattern] selectors)
 
Generator[HistObject, None, None] iterate (self, dryrun)
 
Iterable[HistObject] __iter__ (self)
 
Iterable[HistObject] warmup (self)
 

Public Attributes

 source
 
 classwarnings
 
 selectors
 
 provider
 
 prefix
 
 interval
 

Detailed Description

Definition at line 32 of file atlas_oh.py.

Constructor & Destructor Documentation

◆ __init__()

def python.atlas_oh.OHInputModule.__init__ (   self)

Definition at line 33 of file atlas_oh.py.

33  def __init__(self):
34  self.source = None
35  self.classwarnings = set()
36  self.selectors = None
37 

Member Function Documentation

◆ __iter__()

Iterable[HistObject] python.atlas_oh.OHInputModule.__iter__ (   self)

Definition at line 110 of file atlas_oh.py.

110  def __iter__(self) -> Iterable[HistObject]:
111  return self.iterate(dryrun=False)
112 

◆ configure()

None python.atlas_oh.OHInputModule.configure (   self,
Mapping[str, Any]  options 
)
Configure this module. Potential elements of "options":
source: a string in the format partition/server
prefix: string to prepend to histogram names.

Definition at line 38 of file atlas_oh.py.

38  def configure(self, options: Mapping[str, Any]) -> None:
39  """
40  Configure this module. Potential elements of "options":
41  source: a string in the format partition/server
42  prefix: string to prepend to histogram names.
43  """
44  from ispy import IPCPartition
45  if 'source' not in options:
46  raise ValueError("Must specify 'source' as an "
47  "option to OHInputModule")
48  self.source = options['source']
49  self.partition, self.server, self.provider = self.source.split(';')
50  self.prefix = options.get('prefix', '')
51  if not IPCPartition(self.partition).isValid():
52  raise ValueError(f'Input partition {self.partition} does not exist')
53  log = logging.getLogger(self.__class__.__name__)
54  log.info(f'Using source {self.source}')
55  self.interval = options.get('interval', 5)
56  log.info(f'Check interval is {self.interval} seconds')
57 

◆ iterate()

Generator[HistObject, None, None] python.atlas_oh.OHInputModule.iterate (   self,
  dryrun 
)
Connect to OH; iterate over matching histograms 

Definition at line 62 of file atlas_oh.py.

62  def iterate(self, dryrun) -> Generator[HistObject, None, None]:
63  """ Connect to OH; iterate over matching histograms """
64  import ROOT
65  ROOT.TH1.AddDirectory(ROOT.kFALSE)
66  from oh import OHSubscriber
67  from ispy import IPCPartition, InfoReader
68  import time
69  from collections import deque
70  log = logging.getLogger(self.__class__.__name__)
71  opartition = IPCPartition(self.partition)
72 
73  # Set up two reading methods: a subscriber to new histograms and
74  # a first pass over all histograms.
75  queue = deque()
76  rec = Receiver(queue, f'{self.server}.{self.provider}.{self.prefix}')
77  subs = OHSubscriber(opartition, self.server, rec, True)
78  subs.subscribe_re2(self.server, self.provider, '.*', True)
79 
80  reader = InfoReader(opartition, self.server, rf'{self.provider}\..*')
81  reader.update()
82  log.debug('First pass update')
83  for k in reader.objects:
84  toread = k.replace(f'{self.server}.{self.provider}.','')
85  obj = readobj(opartition, self.server, self.provider, toread, dryrun)
86  log.debug('OH input read '
87  f'{k} as {toread.replace(self.prefix, "")}')
88  yield HistObject(toread.replace(self.prefix, '', 1), obj)
89 
90  if not dryrun:
91  log.info('First pass complete, entering update loop')
92  del reader
93  try:
94  while True:
95  try:
96  time.sleep(self.interval)
97  if len(queue) > 0:
98  log.info('Update detected')
99  while True:
100  yield queue.popleft()
101  except IndexError:
102  pass
103  log.debug('Completed update')
104  finally:
105  subs.unsubscribe_re2(self.server, self.provider, '.*')
106 
107  return
108  yield
109 

◆ setSelectors()

None python.atlas_oh.OHInputModule.setSelectors (   self,
Collection[Pattern]  selectors 
)
Do more later 

Definition at line 58 of file atlas_oh.py.

58  def setSelectors(self, selectors: Collection[Pattern]) -> None:
59  """ Do more later """
60  self.selectors = selectors
61 

◆ warmup()

Iterable[HistObject] python.atlas_oh.OHInputModule.warmup (   self)

Definition at line 113 of file atlas_oh.py.

113  def warmup(self) -> Iterable[HistObject]:
114  return self.iterate(dryrun=True)
115 
116 

Member Data Documentation

◆ classwarnings

python.atlas_oh.OHInputModule.classwarnings

Definition at line 35 of file atlas_oh.py.

◆ interval

python.atlas_oh.OHInputModule.interval

Definition at line 55 of file atlas_oh.py.

◆ prefix

python.atlas_oh.OHInputModule.prefix

Definition at line 50 of file atlas_oh.py.

◆ provider

python.atlas_oh.OHInputModule.provider

Definition at line 49 of file atlas_oh.py.

◆ selectors

python.atlas_oh.OHInputModule.selectors

Definition at line 36 of file atlas_oh.py.

◆ source

python.atlas_oh.OHInputModule.source

Definition at line 34 of file atlas_oh.py.


The documentation for this class was generated from the following file:
configure
bool configure(asg::AnaToolHandle< ITrigGlobalEfficiencyCorrectionTool > &tool, ToolHandleArray< IAsgElectronEfficiencyCorrectionTool > &electronEffToolsHandles, ToolHandleArray< IAsgElectronEfficiencyCorrectionTool > &electronSFToolsHandles, ToolHandleArray< CP::IMuonTriggerScaleFactors > &muonToolsHandles, ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > &photonEffToolsHandles, ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > &photonSFToolsHandles, const std::string &triggers, const std::map< std::string, std::string > &legsPerTool, unsigned long nToys, bool debug)
Definition: TrigGlobEffCorrValidation.cxx:514
python.Bindings.__iter__
__iter__
Definition: Control/AthenaPython/python/Bindings.py:791
isValid
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
Definition: AtlasPID.h:620
python.atlas_oh.readobj
def readobj(part, server, provider, k, dryrun)
Definition: atlas_oh.py:11
CxxUtils::set
constexpr std::enable_if_t< is_bitmask_v< E >, E & > set(E &lhs, E rhs)
Convenience function to set bits in a class enum bitmask.
Definition: bitmask.h:232
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
PrepareReferenceFile.iterate
def iterate(ROOT.TDirectory thisdir, ROOT.TDirectory targetdir, str prefix, typing.Pattern regex, bool excludeTrees)
Definition: PrepareReferenceFile.py:10
Trk::split
@ split
Definition: LayerMaterialProperties.h:38