ATLAS Offline Software
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | List of all members
python.POOL2EI_Lib.POOL2EI Class Reference
Inheritance diagram for python.POOL2EI_Lib.POOL2EI:
Collaboration diagram for python.POOL2EI_Lib.POOL2EI:

Public Member Functions

def __init__ (self, name='POOL2EI', **kw)
 
def initialize (self)
 
def evtStore (self)
 
def inputStore (self)
 
def process_metadata (self, store, metadata_name)
 
def beginFile (self)
 
def endFile (self)
 
def start (self)
 
def execute (self)
 
def finalize (self)
 
virtual StatusCode initialize () override
 
virtual StatusCode reinitialize () override
 
virtual StatusCode start () override
 
virtual StatusCode execute () override
 
virtual StatusCode stop () override
 
virtual StatusCode finalize () override
 
virtual StatusCode sysInitialize () override
 Override sysInitialize. More...
 
virtual const char * typeName () const override
 return the std::type_info name of the underlying py-component This is used by concrete implementations to connect a python component to its C++ counter-part More...
 
virtual PyObjectself () override
 return associated python object. More...
 
 DeclareInterfaceID (IPyComponent, 1, 0)
 
virtual const DataObjIDColl & extraOutputDeps () const override
 Return the list of extra output dependencies. More...
 
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc. More...
 
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc. More...
 
virtual StatusCode sysStart () override
 Handle START transition. More...
 
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles. More...
 
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles. More...
 
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T > &t)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &)
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &)
 Declare a new Gaudi property. More...
 
Gaudi::Details::PropertyBase * declareProperty (const std::string &name, T &property, const std::string &doc="none")
 Declare a new Gaudi property. More...
 
void updateVHKA (Gaudi::Details::PropertyBase &)
 
MsgStream & msg () const
 
MsgStream & msg (const MSG::Level lvl) const
 
bool msgLvl (const MSG::Level lvl) const
 

Public Attributes

 eipbof
 
 guids
 
 guid
 

Protected Member Functions

virtual bool setPyAttr (PyObject *pyobj) override
 attach the C++ component to its python cousin More...
 
void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Protected Attributes

PyObjectm_self
 Pointer to self (from the python world) More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

 _dsname
 
 _dsname_orig
 
 _eif_spb
 
 _initialized
 
 _eif_entries
 
DataObjIDColl m_extendedExtraObjects
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Static Private Attributes

 _iov = IOV()
 
 _eif = None
 
int _eif_entries = 0
 
int _eif_totentries = 0
 
int _eif_nfiles = 0
 
 _eifname = None
 
 _eifname_spb = None
 
bool _initialized = False
 
int _eiversion = 0x00000001
 
int _eimagic = 0x6e56c8c7
 

Detailed Description

Algorithm

Definition at line 46 of file POOL2EI_Lib.py.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< Algorithm > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ __init__()

def python.POOL2EI_Lib.POOL2EI.__init__ (   self,
  name = 'POOL2EI',
**  kw 
)

Definition at line 61 of file POOL2EI_Lib.py.

61  def __init__(self, name='POOL2EI', **kw):
62  # init base class
63  super(POOL2EI, self).__init__(name, **kw)
64 
65  _info = self.msg.info
66  _info("POOL2EI::__init__")
67 

Member Function Documentation

◆ beginFile()

def python.POOL2EI_Lib.POOL2EI.beginFile (   self)

Definition at line 299 of file POOL2EI_Lib.py.

299  def beginFile(self):
300 
301  _info = self.msg.info
302  _info("POOL2EI::beginFile")
303 
304  # entries for this input file
305  self._eif_entries = 0
306 
307  # define a new IOV storage
308  self._iov = IOV()
309 
310  # ======================================================
311  # retrieve the GUID
312  # ======================================================
313 
314  def _get_guid():
315  ROOT = _import_ROOT()
316  root_files = list(ROOT.gROOT.GetListOfFiles())
317  if len(root_files) == 0:
318  _info('could not find correct ROOT file')
319  return
320 
321  root_file = root_files[-1] # get the last file in the list
322  pool = root_file.Get("##Params")
323  import re
324  # Pool parameters are of the form:
325  # '[NAME=somevalue][VALUE=thevalue]'
326  pool_token = re.compile(r'\[NAME=(?P<name>.*?)\]'
327  r'\[VALUE=(?P<value>.*?)\]').match
328  params = []
329  guids = []
330  for i in range(pool.GetEntries()):
331  if pool.GetEntry(i) > 0:
332  pool_string = pool.db_string
333  # take string until \0 is found
334  n = pool_string.find('\0')
335  if n != -1:
336  pool_string = pool_string[:n]
337  match = pool_token(pool_string)
338  if not match:
339  continue
340  d = match.groupdict()
341  params.append((d['name'], d['value']))
342  if d['name'].lower() == 'fid':
343  guids.append(d['value'])
344  return guids
345 
346  self.guids = _get_guid()
347  if len(self.guids) > 0:
348  self.guid = self.guids.pop()
349  else:
350  self.guid = None
351 
352  # ======================================================
353  # trigger menu
354  # ======================================================
355  if self.DoTriggerInfo:
356  l1_menu = None
357  l2_menu = None
358  ef_menu = None
359  hlt_menu = None
360  if self.meta_triggermenu:
361  _info("Load trigger menu from TriggerMenu")
362  for e in self.inputStore['TriggerMenu']:
363  smk = e.smk()
364  l1psk = e.l1psk()
365  hltpsk = e.hltpsk()
366  chainIds = e.chainIds()
367  chainNames = e.chainNames()
368  itemCtpIds = e.itemCtpIds()
369  itemNames = e.itemNames()
370  l1_menu = {name: id for id, name in
371  zip(itemCtpIds, itemNames)}
372  hlt_menu = {name: id for id, name in
373  zip(chainIds, chainNames)}
374  break # first element is enough
375 
376  elif self.meta_triggermenujson_l1 or self.meta_triggermenujson_hlt:
377  _info("Load trigger menu from TriggerMenuJson_L1 and "
378  "TriggerMenuJson_HLT")
379  import json
380  for e in self.inputStore['TriggerMenuJson_L1']:
381  l1_menu_raw = json.loads(e.payload())
382  l1_items = l1_menu_raw['items']
383  l1_menu = {l1_key: l1_items[l1_key]['ctpid']
384  for l1_key in l1_items}
385  break # first element is enough
386  for e in self.inputStore['TriggerMenuJson_HLT']:
387  hlt_menu_raw = json.loads(e.payload())
388  hlt_chains = hlt_menu_raw['chains']
389  hlt_menu = {chain: hlt_chains[chain]['counter']
390  for chain in hlt_chains}
391  break # first element is enough
392  elif self.meta_hlt_menu or self.meta_lvl1_menu:
393  _info("Load trigger menu from /TRIGGER/LVL1/Menu and "
394  "/TRIGGER/HLT/Menu")
395  # /TRIGGER/LVL1/Menu
396  (l1menu_info, l1menu_iovs) = self.process_metadata(
397  self.inputStore, '/TRIGGER/LVL1/Menu')
398  # bit mask number is in channel IOV
399  channels = [iov[6] for iov in l1menu_iovs]
400  names = [e['ItemName'] for e in l1menu_info[0]]
401  l1_menu = {name: id for name, id in zip(names, channels)}
402 
403  # /TRIGGER/HLT/Menu
404  (hltmenu_info, hltmenu_iovs) = self.process_metadata(
405  self.inputStore, '/TRIGGER/HLT/Menu')
406  l2_menu = {entry['ChainName']: entry['ChainCounter']
407  for entry in hltmenu_info[0]
408  if entry['ChainName'].startswith("L2_")}
409  ef_menu = {entry['ChainName']: entry['ChainCounter']
410  for entry in hltmenu_info[0]
411  if entry['ChainName'].startswith("EF_")}
412  hlt_menu = {entry['ChainName']: entry['ChainCounter']
413  for entry in hltmenu_info[0]
414  if entry['ChainName'].startswith("HLT_")}
415  else:
416  _info("Trigger Menu not found")
417 
418  # ======================================================
419  # trigger config keys
420  # ======================================================
421  smk = 0
422  l1psk = 0
423  hltpsk = 0
424  if self.meta_triggermenu:
425  _info("Load trigger config keys from TriggerMenu")
426  for e in self.inputStore['TriggerMenu']:
427  smk = e.smk()
428  l1psk = e.l1psk()
429  hltpsk = e.hltpsk()
430  break # first element is enough
431  if self.meta_hlt_hltconfigkeys:
432  _info("Load trigger config keys from /TRIGGER/HLT/HltConfigKeys")
433  # /TRIGGER/HLT/HltConfigKeys
434  (hltck_info, hltck_iovs) = self.process_metadata(
435  self.inputStore, '/TRIGGER/HLT/HltConfigKeys')
436  smk_l = [x['MasterConfigurationKey'] for x in hltck_info]
437  for val, iov in zip(smk_l, hltck_iovs):
438  self._iov.add('SMK', val, iov[:4])
439  smk = smk_l[0]
440  if self.meta_hlt_prescalekey:
441  _info("Load trigger config keys from /TRIGGER/HLT/PrescaleKey")
442  # /TRIGGER/HLT/PrescaleKey
443  (hltpk_info, hltpk_iovs) = self.process_metadata(
444  self.inputStore, '/TRIGGER/HLT/PrescaleKey')
445  hltpk_l = [x['HltPrescaleKey'] for x in hltpk_info]
446  for val, iov in zip(hltpk_l, hltpk_iovs):
447  self._iov.add('HLTPSK', val, iov[:4])
448  hltpsk = hltpk_l[0]
449  if self.meta_lvl1_lvl1configkey:
450  _info("Load trigger config keys from /TRIGGER/LVL1/Lvl1ConfigKey")
451  # /TRIGGER/LVL1/Lvl1ConfigKey
452  (l1pk_info, l1pk_iovs) = self.process_metadata(
453  self.inputStore, '/TRIGGER/LVL1/Lvl1ConfigKey')
454  l1pk_l = [x['Lvl1PrescaleConfigurationKey'] for x in l1pk_info]
455  for val, iov in zip(l1pk_l, l1pk_iovs):
456  self._iov.add('L1PSK', val, iov[:4])
457  l1psk = l1pk_l[0]
458 
459  # ======================================================
460  # AMITag, triggerStreamOfFile and project_name
461  # ======================================================
462  _info("Load AMITag, triggerStreamOfFile and project_name "
463  "from /TagInfo")
464 
465  (tginfo, tgiovs) = self.process_metadata(self.inputStore, '/TagInfo')
466  amitag = "Unknown"
467  trigStream = "Unknown"
468  projName = "Unknown"
469  if len(tginfo) > 0:
470  for tgi in tginfo:
471  if 'AMITag' in tgi:
472  amitag = tgi['AMITag']
473  _info("## AMITag: {}".format(amitag))
474  if 'triggerStreamOfFile' in tgi:
475  trigStream = tgi['triggerStreamOfFile']
476  _info("## triggerStreamOfFile: {}".format(trigStream))
477  if 'project_name' in tgi:
478  projName = tgi['project_name']
479  _info("## project_name: {}".format(projName))
480 
481  # ======================================================
482  # write BeginGUID
483  # ======================================================
484 
485  if self._eif_spb is not None:
486  beginGUID = self.eipbof.BeginGUID()
487  beginGUID.startProcTime = int(time.time() * 1000)
488  beginGUID.AMITag = str(amitag)
489  beginGUID.trigStream = str(trigStream)
490  beginGUID.projName = str(projName)
491  beginGUID.guid = self.guid
492 
493  spb = beginGUID.SerializeToString()
494  self._eif_spb.write(struct.pack('<I', eic.EI_PROTO_BEGINGUID << 8 |
495  eic.EI_PROTO_MSGVER))
496  self._eif_spb.write(struct.pack('<I', len(spb)))
497  self._eif_spb.write(spb)
498 
499  self._eif_nfiles += 1
500 
501  # ======================================================
502  # write TriggerMenu
503  # ======================================================
504 
505  if (self.DoTriggerInfo and self._eif_spb is not None
506  and l1_menu is not None):
507  _info("Write trigger menu to output SPB")
508  tMenu = self.eipbof.TriggerMenu()
509  tMenu.SMK = smk
510  tMenu.L1PSK = l1psk
511  tMenu.HLTPSK = hltpsk
512 
513  def d2l(d):
514  menu = ["{}:{}".format(d[k], k) for k in d]
515  return ";".join(menu)
516 
517  if l1_menu is not None and len(l1_menu) > 0:
518  tMenu.L1Menu = d2l(l1_menu)
519  if l2_menu is not None and len(l2_menu) > 0:
520  tMenu.L2Menu = d2l(l2_menu)
521  if ef_menu is not None and len(ef_menu) > 0:
522  tMenu.EFMenu = d2l(ef_menu)
523  if hlt_menu is not None and len(hlt_menu) > 0:
524  tMenu.HLTMenu = d2l(hlt_menu)
525 
526  # tMenu.L1Menu is required
527  if len(tMenu.L1Menu) > 0:
528  spb = tMenu.SerializeToString()
529  self._eif_spb.write(struct.pack('<I',
530  eic.EI_PROTO_TRIGGERMENU << 8 |
531  eic.EI_PROTO_MSGVER))
532  self._eif_spb.write(struct.pack('<I', len(spb)))
533  self._eif_spb.write(spb)
534  else:
535  _info("Unable to write trigger menu to output SPB. "
536  "tMenu.L1Menu is empty")
537 
538  self.inputStore.clearStore()
539 
540  return
541 

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ DeclareInterfaceID()

IPyComponent::DeclareInterfaceID ( IPyComponent  ,
,
 
)
inherited

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleBase. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 245 of file AthCommonDataStore.h.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation string for the property.

This is the version for types that derive from SG::VarHandleKey. The property value object is put on the input and output lists as appropriate; then we forward to the base class.

Definition at line 221 of file AthCommonDataStore.h.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This is the generic version, for types that do not derive from SG::VarHandleKey. It just forwards to the base class version of declareProperty.

Definition at line 333 of file AthCommonDataStore.h.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation string for the property.

This dispatches to either the generic declareProperty or the one for VarHandle/Key/KeyArray.

Definition at line 352 of file AthCommonDataStore.h.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ endFile()

def python.POOL2EI_Lib.POOL2EI.endFile (   self)

Definition at line 545 of file POOL2EI_Lib.py.

545  def endFile(self):
546 
547  _info = self.msg.info
548  _info("POOL2EI::endFile")
549 
550  # write EndGUID
551  if self._eif_spb is not None:
552  endGUID = self.eipbof.EndGUID()
553  endGUID.nentries = self._eif_entries
554  endGUID.endProcTime = int(time.time() * 1000)
555 
556  spb = endGUID.SerializeToString()
557  self._eif_spb.write(struct.pack('<I', eic.EI_PROTO_ENDGUID << 8 |
558  eic.EI_PROTO_MSGVER))
559  self._eif_spb.write(struct.pack('<I', len(spb)))
560  self._eif_spb.write(spb)
561 
562  self.inputStore.clearStore()
563 
564  return
565 

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< Algorithm > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

def python.POOL2EI_Lib.POOL2EI.evtStore (   self)

Definition at line 196 of file POOL2EI_Lib.py.

196  def evtStore(self):
197  import AthenaPython.PyAthena as PyAthena
198  return PyAthena.py_svc('StoreGateSvc/StoreGateSvc')
199 

◆ execute() [1/2]

StatusCode PyAthena::Alg::execute ( )
overridevirtualinherited

Definition at line 93 of file PyAthenaAlg.cxx.

94 {
95 // ATH_MSG_DEBUG("Executing " << name() << "...");
97  PyObject* pycontext = PyCapsule_New ( const_cast<EventContext*>(&getContext()), nullptr, nullptr);
98 
99  StatusCode sc = PyAthena::callPyMethod( m_self, "sysExecute", pycontext );
100  Py_DECREF (pycontext);
101  return sc;
102 }

◆ execute() [2/2]

def python.POOL2EI_Lib.POOL2EI.execute (   self)

Definition at line 579 of file POOL2EI_Lib.py.

579  def execute(self):
580 
581  if self._eif_totentries < 100:
582  _info = self.msg.info
583  else:
584  _info = lambda *x: None # noqa: E731
585  _warning = self.msg.warning
586 
587  _info("POOL2EI::execute")
588 
589  if self._eif_spb is not None:
590  eventPB = self.eipbof.EIEvent()
591 
592  # ======================================================
593  # Get EventInfo data
594  # ======================================================
595 
596  store = self.evtStore
597 
598  if self.item_xaod_eventinfo:
599 
600  _info('=== [xAOD::EventInfo] ===')
601  xei = store.retrieve('xAOD::EventInfo', 'EventInfo')
602  run_number = xei.runNumber()
603  event_number = xei.eventNumber()
604  lumi_block = xei.lumiBlock()
605  bunch_crossing_id = xei.bcid()
606  time_stamp = xei.timeStamp()
607  try:
608  time_stamp_ns = xei.timeStampNSOffset()
609  except Exception:
610  _info('## Event does not have xAOD::EventInfo::'
611  'timeStampNSOffset()')
612  time_stamp_ns = 0
613  evt_type_bit_mask = xei.eventTypeBitmask()
614  isSimulation = (evt_type_bit_mask & xei.IS_SIMULATION != 0)
615  isTestBeam = (evt_type_bit_mask & xei.IS_TESTBEAM != 0)
616  isCalibration = (evt_type_bit_mask & xei.IS_CALIBRATION != 0)
617  mc_channel_number = 0
618  mc_event_weight = 0.
619  if isSimulation:
620  try:
621  mc_channel_number = xei.mcChannelNumber()
622  mc_event_weight = xei.mcEventWeight()
623  except Exception:
624  pass
625  try:
626  extendedLevel1ID = xei.extendedLevel1ID()
627  except Exception:
628  _info('## Event does not have xAOD::EventInfo::'
629  'extendedLevel1ID()')
630  extendedLevel1ID = 0
631  # there isn't eInfoTrigger in xAOD::EventInfo
632  eInfoTrigger = None
633 
634  del xei
635 
636  elif self.item_eventinfo:
637 
638  # evt_info_keys = store.keys('EventInfo') # fails. bug ?
639  evt_info_keys = [
640  x for x in store.keys() if x.endswith("EventInfo")]
641  if len(evt_info_keys) != 1:
642  _info('more than one EventInfo: {}'.format(evt_info_keys))
643  _info(' ==> we\'ll use [{}]'.format(evt_info_keys[0]))
644  sg_key = evt_info_keys[0]
645  ei = store.retrieve('EventInfo', sg_key)
646  _info('=== [EventInfo#{}] ==='.format(sg_key))
647  eid = ei.event_ID()
648  run_number = eid.run_number()
649  event_number = eid.event_number()
650  lumi_block = eid.lumi_block()
651  bunch_crossing_id = eid.bunch_crossing_id()
652  time_stamp = eid.time_stamp()
653  time_stamp_ns = eid.time_stamp_ns_offset()
654  eitype = ei.event_type()
655  mc_channel_number = eitype.mc_channel_number()
656  mc_event_weight = eitype.mc_event_weight()
657  bm = list(eitype.bit_mask)
658  # IS_SIMULATION / IS_DATA
659  isSimulation = True if 'IS_SIMULATION' in bm else False
660  # IS_TESTBEAM / IS_FROM_ATLAS_DET
661  isTestBeam = True if 'IS_TESTBEAM' in bm else False
662  # IS_CALIBRATION / IS_PHYSICS
663  isCalibration = True if 'IS_CALIBRATION' in bm else False
664  extendedLevel1ID = 0
665  eInfoTrigger = ei.trigger_info()
666  extendedLevel1ID = eInfoTrigger.extendedLevel1ID()
667 
668  del ei
669 
670  else:
671  # FAIL
672  raise RuntimeError('Unable to find neither '
673  'xAOD::EventInfo nor EventInfo')
674 
675  _info('## run_number: {:d}'.format(run_number))
676  _info('## event_number: {:d}'.format(event_number))
677  _info('## bunch_crossing_id: {:d}'.format(bunch_crossing_id))
678  _info('## extendedLevel1ID: {:d}'.format(extendedLevel1ID))
679  _info('## lumi_block: {:d}'.format(lumi_block))
680  _info('## time_stamp: {:d}'.format(time_stamp))
681  _info('## time_stamp_ns_offset: {:d}'.format(time_stamp_ns))
682  _info('## EventWeight: {:f}'.format(mc_event_weight))
683  _info('## McChannelNumber: {:d}'.format(mc_channel_number))
684  _info('## isSimulation: {}'.format(isSimulation))
685  _info('## isTestBeam: {}'.format(isTestBeam))
686  _info('## isCalibration: {}'.format(isCalibration))
687 
688  if self._eif_spb is not None:
689  eventPB.runNumber = run_number
690  eventPB.eventNumber = event_number
691  eventPB.lumiBlock = lumi_block
692  eventPB.bcid = bunch_crossing_id
693  eventPB.timeStamp = time_stamp
694  eventPB.timeStampNSOffset = time_stamp_ns
695  eventPB.mcEventWeight = mc_event_weight
696  eventPB.mcChannelNumber = mc_channel_number
697  eventPB.isSimulation = isSimulation
698  eventPB.isCalibration = isCalibration
699  eventPB.isTestBeam = isTestBeam
700  eventPB.extendedLevel1ID = extendedLevel1ID
701 
702  # ======================================================
703  # Trigger conf keys
704  # ======================================================
705 
706  if self.item_xaod_TrigConfKeys:
707  _info("Retrieve TrigConfKeys from xAOD::TrigConfKeys")
708  tck = store.retrieve('xAOD::TrigConfKeys', 'TrigConfKeys')
709  evt_smk = tck.smk()
710  evt_l1psk = tck.l1psk()
711  evt_hltpsk = tck.hltpsk()
712  del tck
713  elif (self.meta_hlt_hltconfigkeys or self.meta_hlt_prescalekey
714  or self.meta_lvl1_lvl1configkey):
715  _info("Retrieve TrigConfKeys from /TRIGGER/**")
716  evt_smk = self._iov.get('SMK', (run_number, event_number))
717  evt_l1psk = self._iov.get('L1PSK', (run_number, lumi_block))
718  evt_hltpsk = self._iov.get('HLTPSK', (run_number, lumi_block))
719  else:
720  _info("Unable to retrieve TrigConfKeys")
721  evt_smk = 0
722  evt_l1psk = 0
723  evt_hltpsk = 0
724 
725  _info('## smk: {}'.format(evt_smk))
726  _info('## hltpsk: {}'.format(evt_hltpsk))
727  _info('## l1psk: {}'.format(evt_l1psk))
728 
729  if self._eif_spb is not None:
730  eventPB.SMK = evt_smk
731  eventPB.HLTPSK = evt_hltpsk
732  eventPB.L1PSK = evt_l1psk
733 
734  # ======================================================
735  # Trigger bit masks
736  # ======================================================
737 
738  if self.DoTriggerInfo:
739 
740  def v2b(v): # vector elements to binary string
741  res = ""
742  for e in v:
743  res += "{0:032b}".format(e)[::-1]
744  return res
745 
746  trigL1 = ""
747  trigL2 = ""
748  trigEF = ""
749 
750  if self.item_xaod_TrigDecision:
751 
752  _info("Get trigger bit masks form xAOD::TrigDecision")
753 
754  # retrieve xTrigDecision
755  xtd = store.retrieve('xAOD::TrigDecision', 'xTrigDecision')
756 
757  # L1
758  tbp = xtd.tbp() # vector: 16 elements of 32 bits = 512 bits
759  tap = xtd.tap()
760  tav = xtd.tav()
761  trigL1 = compressB64(v2b(tbp) + v2b(tap) + v2b(tav))
762  del tbp
763  del tap
764  del tav
765 
766  # L2
767  trigL2_PH = xtd.lvl2PassedPhysics() # 256*32 bits = 8192 bits
768  trigL2_PT = xtd.lvl2PassedThrough()
769  trigL2_RS = xtd.lvl2Resurrected()
770  trigL2 = "{};{};{}".format(
771  compressB64(v2b(trigL2_PH)),
772  compressB64(v2b(trigL2_PT)),
773  compressB64(v2b(trigL2_RS)))
774  del trigL2_PH
775  del trigL2_PT
776  del trigL2_RS
777 
778  # EF
779  trigEF_PH = xtd.efPassedPhysics() # 256*32 bits = 8192 bits
780  trigEF_PT = xtd.efPassedThrough()
781  trigEF_RS = xtd.efResurrected()
782  trigEF = "{};{};{}".format(
783  compressB64(v2b(trigEF_PH)),
784  compressB64(v2b(trigEF_PT)),
785  compressB64(v2b(trigEF_RS)))
786  del trigEF_PH
787  del trigEF_PT
788  del trigEF_RS
789 
790  del xtd
791 
792  else:
793 
794  _info("Get trigger bit masks form eventInfo.trigger_info()")
795 
796  # get trigger from eventInfo.trigger_info()
797  if eInfoTrigger is not None:
798  trigL1 = compressB64(v2b(eInfoTrigger.level1TriggerInfo()))
799  trigL2 = compressB64(v2b(eInfoTrigger.level2TriggerInfo()))
800  trigEF = compressB64(v2b(eInfoTrigger.eventFilterInfo()))
801 
802  _info("## trigL1: {}".format(trigL1))
803  _info("## trigL2: {}".format(trigL2))
804  _info("## trigEF: {}".format(trigEF))
805 
806  if self._eif_spb is not None:
807 
808  eventPB.L1PassedTrigMask = trigL1
809  eventPB.L2PassedTrigMask = trigL2
810  eventPB.EFPassedTrigMask = trigEF
811 
812  if eInfoTrigger is not None:
813  del eInfoTrigger
814 
815  # ======================================================
816  # Self reference and Provenance
817  # ======================================================
818 
819  def guid2string(guid):
820  # get guid as string
821  # native method toString() seems to produce a memory leak
822  # use getters for class Guid
823  # data1(), data2(), data3() are translated to integers in python
824  # data4(i) is translated from char in C++ to string in python
825  s="{:08X}-{:04X}-{:04X}-{:02X}{:02X}-{:02X}{:02X}{:02X}{:02X}{:02X}{:02X}".format(
826  guid.data1(), guid.data2(), guid.data3(),
827  ord(guid.data4(0)[0]), ord(guid.data4(1)[0]),
828  ord(guid.data4(2)[0]), ord(guid.data4(3)[0]),
829  ord(guid.data4(4)[0]), ord(guid.data4(5)[0]),
830  ord(guid.data4(6)[0]), ord(guid.data4(7)[0]))
831  return s
832 
833  def token2string (tk, replace_empty_cntID=False):
834  # get token as string
835  # native method toString() seems to produce a memory leak
836  # use getter for class Token
837  cntID = tk.contID()
838  if replace_empty_cntID and cntID == "":
839  cntID = "POOLContainer(DataHeader)"
840  stk = "[DB={}][CNT={}][CLID={}][TECH={:08X}][OID={:016X}-{:016X}]".format(
841  guid2string(tk.dbID()), cntID, guid2string(tk.classID()),
842  tk.technology(), tk.oid().first, tk.oid().second)
843  return stk
844 
845  Pstream_refs = {} # provenance references
846  procTag = None
847 
848  # -- Stream references
849  dh = store.retrieve('DataHeader', 'EventSelector')
850  procTag = dh.getProcessTag()
851 
852  if procTag == "":
853  # pacth procTag ATEAM-782
854  for el in dh.elements():
855  if el.getPrimaryClassID() == 222376821:
856  procTag = el.getKey()
857  break
858  _info("## ProcessTag: " + procTag)
859 
860  if self.DoProvenanceRef:
861 
862  # get provenance references
863  if dh.sizeProvenance() > 0:
864  prv = dh.beginProvenance()
865  for i in range(dh.sizeProvenance()):
866  key = prv.getKey()
867  tk = prv.getToken()
868  if key.startswith("Output"):
869  _warning('Provenance token starts with Output: {}'
870  .format(key))
871  key = key[6:]
872  if key.startswith("Input"):
873  _warning('Provenance token starts with Input: {}'
874  .format(key))
875  key = key[5:]
876  # CNT might be empty. Complete information
877  if key == "StreamRAW":
878  stk = token2string(tk, replace_empty_cntID=False)
879  elif key in ("StreamAOD", "StreamESD", "StreamRDO",
880  "StreamHITS", "StreamEVGEN",
881  "EmbeddingStream"):
882  stk = token2string(tk, replace_empty_cntID=True)
883  else:
884  stk = token2string(tk, replace_empty_cntID=False)
885  _info("provenance {}={}".format(key, stk))
886  _info('Unknown provenance stream: {}'.format(key))
887  # do not raise error, just continue. mar-2024
888  # _error('Unknown provenance stream: {}'.format(key))
889  # raise RuntimeError('Unknown provenance stream')
890  del tk
891  del key
892  prv += 1
893  continue
894  _info("## P" + key + "_ref: " + stk)
895  if key not in Pstream_refs:
896  # keep only the first provenance found for each straam
897  Pstream_refs[key] = stk
898  del tk
899  del key
900  prv += 1
901  del prv
902 
903 
904  # get self reference.
905  # look for the processing tag key in the Data Object vector
906  if self._eif_spb is not None:
907  tokenPB0 = eventPB.eitoken.add()
908  if dh.size() > 0:
909  dhe = dh.begin()
910  for i in range(dh.size()):
911  key = dhe.getKey()
912  if key.startswith('Stream'):
913  _info("## Stream: " + key)
914  if key in [procTag, 'StreamAOD']:
915  tk = dhe.getToken()
916  stk = token2string(tk, replace_empty_cntID=True)
917  _info("## " + key + "_ref: " + stk)
918  if self._eif_spb is not None:
919  if key == tokenPB0.name:
920  _info("Already inserted key {0} in tokenPB0 "
921  "with value {1}".format(key, stk))
922  tokenPB0.name = key
923  tokenPB0.token = stk
924  del tk
925  del key
926  dhe += 1
927  dh.end()
928  del dhe
929 
930  # Update self reference token to handle fast merged files.
931  try:
932  stk = store.proxy(dh).address().par().c_str()
933  if self._eif_spb is not None:
934  tokenPB0.token = stk
935  _info("Updated ref token " + stk)
936  del stk
937  except Exception:
938  pass
939 
940  # write provenance to protbuf message
941  if self._eif_spb is not None:
942  for sr in Pstream_refs:
943  try:
944  tokenPB = eventPB.eitoken.add()
945  tokenPB.name = sr
946  tokenPB.token = Pstream_refs[sr]
947  except Exception:
948  _info("Unable to insert {} in provenance stream "
949  "references with value {}".format(
950  sr, Pstream_refs[sr]))
951  pass
952 
953  del dh
954 
955  # ======================================================
956  # Write event EI
957  # ======================================================
958 
959  if self._eif_spb is not None:
960  spb = eventPB.SerializeToString()
961  self._eif_spb.write(struct.pack('<I', eic.EI_PROTO_EIEVENT << 8 |
962  eic.EI_PROTO_MSGVER))
963  self._eif_spb.write(struct.pack('<I', len(spb)))
964  self._eif_spb.write(spb)
965  del eventPB
966  if (self._eif_entries % 1000 == 0):
967  self._eif_spb.flush()
968 
969  self._eif_entries += 1 # for this input file
970  self._eif_totentries += 1 # for all input files
971 
972  store.clearStore()
973 
974  return StatusCode.Success
975 

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ extraOutputDeps()

const DataObjIDColl & AthAlgorithm::extraOutputDeps ( ) const
overridevirtualinherited

Return the list of extra output dependencies.

This list is extended to include symlinks implied by inheritance relations.

Definition at line 50 of file AthAlgorithm.cxx.

51 {
52  // If we didn't find any symlinks to add, just return the collection
53  // from the base class. Otherwise, return the extended collection.
54  if (!m_extendedExtraObjects.empty()) {
56  }
57  return Algorithm::extraOutputDeps();
58 }

◆ finalize() [1/2]

StatusCode PyAthena::Alg::finalize ( )
overridevirtualinherited

Definition at line 86 of file PyAthenaAlg.cxx.

87 {
88  ATH_MSG_INFO("Finalizing " << name() << "...");
89  return PyAthena::callPyMethod( m_self, "sysFinalize" );
90 }

◆ finalize() [2/2]

def python.POOL2EI_Lib.POOL2EI.finalize (   self)

Definition at line 979 of file POOL2EI_Lib.py.

979  def finalize(self):
980 
981  _info = self.msg.info
982  _info("POOL2EI::finalize")
983 
984  if self._eif_spb is not None:
985  trailer = self.eipbof.Trailer()
986  trailer.nfiles = self._eif_nfiles
987  trailer.nentries = self._eif_totentries
988  trailer.endProcTime = int(time.time() * 1000)
989 
990  spb = trailer.SerializeToString()
991  self._eif_spb.write(struct.pack('<I', eic.EI_PROTO_TRAILER << 8 |
992  eic.EI_PROTO_MSGVER))
993  self._eif_spb.write(struct.pack('<I', len(spb)))
994  self._eif_spb.write(spb)
995 
996  self._eif_spb.close()
997 
998  _info("Total number of events processed: {}".format(self._eif_totentries))
999 
1000  return StatusCode.Success
1001 

◆ initialize() [1/2]

StatusCode PyAthena::Alg::initialize ( )
overridevirtualinherited

Definition at line 60 of file PyAthenaAlg.cxx.

61 {
62  ATH_MSG_INFO("Initializing " << name() << "...");
63  return PyAthena::callPyMethod( m_self, "sysInitialize" );
64 }

◆ initialize() [2/2]

def python.POOL2EI_Lib.POOL2EI.initialize (   self)

Definition at line 72 of file POOL2EI_Lib.py.

72  def initialize(self):
73 
74  import AthenaPython.PyAthena as PyAthena
75  _info = self.msg.info
76  _info("POOL2EI::initialize")
77 
78  # Am I being called for every input file ?
79  if self._initialized:
80  return
81 
82  _info("## DoProvenanceRef: {}".format(self.DoProvenanceRef))
83  _info("## DoTriggerInfo: {}".format(self.DoTriggerInfo))
84  _info("## SendToBroker: {}".format(self.SendToBroker))
85 
86  self.eipbof = EIPBof(self._eiversion) # initialize factory
87 
88  self._dsname = "Unknown.Input.Dataset.Name" # default fake value
89  if self.EiDsName is not None:
90  _info("## EiDsName: {}".format(self.EiDsName))
91  self._dsname = self.EiDsName
92  else:
93  # try to get dataset name from pathena INDS environment variable
94  inds = os.getenv('INDS')
95  if inds is not None:
96  _info("## INDS: {}".format(inds))
97  self._dsname = inds
98  else:
99  # else, try to use job definition
100  try:
101  import newJobDef
102  processingType = newJobDef.job['processingType']
103  transformation = newJobDef.job['transformation']
104  dsSource = 'realDatasetsIn' # dataset name from input
105  if (processingType == 'merge' and
106  transformation != 'POOLtoEI_tf.py'):
107  dsSource = 'realDatasets' # dataset name from output
108  datasets = newJobDef.job[dsSource].split(',')
109  _info("## {}[0]: {}".format(dsSource, datasets[0]))
110  self._dsname = datasets[0]
111  except Exception:
112  _info('## Unable to get dataset name from realDatasetsIn '
113  'or realDatasets')
114 
115  # remove _tid and _sub parts from dsname
116  import re
117  self._dsname_orig = self._dsname
118  self._dsname = re.sub('_tid[0-9]{8}_[0-9]{2}', '', self._dsname)
119  self._dsname = re.sub('_sub[0-9]{10}', '', self._dsname)
120  self._dsname = re.sub('/$', '', self._dsname)
121 
122  # load our pythonizations:
123  for cls_name in ('EventStreamInfo', 'EventType', 'PyEventType'):
124  cls = getattr(PyAthena, cls_name) # noqa: F841
125 
126  _info("retrieving various stores...")
127  for store_name in ('evtStore', 'inputStore'):
128  _info("retrieving [{}]...".format(store_name))
129  o = getattr(self, store_name) # noqa: F841
130  _info("retrieving [{}]... [done]".format(store_name))
131  _info("retrieving various stores... [done]")
132 
133  # Build output file names
134  # self.EiFmt ignored
135  # keep self.EiFmt format flag for compatibility and future usage
136  if self.Out is not None:
137  oname_spb = self.Out
138  else:
139  oname_spb = "output.ei.spb"
140 
141  # open EI output file
142  oname_spb = os.path.expanduser(os.path.expandvars(oname_spb))
143  self._eifname_spb = oname_spb
144  _info('Opening EI SPB file [{}]...'.format(oname_spb))
145 
146  if os.path.exists(oname_spb):
147  os.remove(oname_spb)
148 
149  try:
150  self._eif_spb = gzip.open(oname_spb, 'wb')
151  except Exception:
152  self._eif_spb = None
153  self.msg.fatal("Unable to open EI SPB output file {} "
154  "exapnded as {}".format(self.Out, oname_spb))
155  raise RuntimeError("Unable to open EI SPB output file")
156 
157  self._eif_spb.write(struct.pack('<I', self._eimagic)) # EI SPB magic
158  self._eif_spb.write(struct.pack('<I', self._eiversion)) # EI SPB ver
159 
160  # get taskid and jobid
161  if (hasattr(self, 'TaskID') and hasattr(self, 'JobID') and
162  self.TaskID is not None and self.JobID is not None):
163  taskID = "{}.T".format(self.TaskID)
164  if (hasattr(self, 'AttemptNumber') and
165  self.AttemptNumber is not None):
166  jobID = "{}.{}".format(self.JobID, self.AttemptNumber)
167  else:
168  jobID = "{}.0".format(self.JobID)
169  else:
170  taskID = "{}.G".format(os.getenv('PanDA_TaskID', 0))
171  jobID = "{}.{}".format(os.getenv('PandaID', 0),
172  os.getenv('PanDA_AttemptNr', 0))
173 
174  # initial information SPB
175  # write Header
176  if self._eif_spb is not None:
177  header = self.eipbof.Header()
178  header.startProcTime = int(time.time() * 1000)
179  header.taskID = taskID
180  header.jobID = jobID
181  header.inputDsName = self._dsname_orig
182  header.provenanceRef = self.DoProvenanceRef
183  header.triggerInfo = self.DoTriggerInfo
184 
185  spb = header.SerializeToString()
186  self._eif_spb.write(struct.pack('<I', eic.EI_PROTO_HEADER << 8 |
187  eic.EI_PROTO_MSGVER))
188  self._eif_spb.write(struct.pack('<I', len(spb)))
189  self._eif_spb.write(spb)
190 
191  self._initialized = True
192 
193  return StatusCode.Success
194 

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< Algorithm > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ inputStore()

def python.POOL2EI_Lib.POOL2EI.inputStore (   self)

Definition at line 201 of file POOL2EI_Lib.py.

201  def inputStore(self):
202  import AthenaPython.PyAthena as PyAthena
203  return PyAthena.py_svc('StoreGateSvc/InputMetaDataStore')
204 

◆ msg() [1/2]

MsgStream& AthCommonMsg< Algorithm >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< Algorithm >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ msgLvl()

bool AthCommonMsg< Algorithm >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< Algorithm > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ process_metadata()

def python.POOL2EI_Lib.POOL2EI.process_metadata (   self,
  store,
  metadata_name 
)

Definition at line 205 of file POOL2EI_Lib.py.

205  def process_metadata(self, store, metadata_name):
206  msg = self.msg
207  try:
208  obj = store[metadata_name]
209  except KeyError:
210  msg.warning('could not retrieve [{}]'.format(metadata_name))
211  return ([], [])
212  try:
213  msg.info('processing container [{}]'.format(obj.folderName()))
214  except Exception:
215  msg.info('container does not have folderName')
216  data = []
217  iovs = []
218  payloads = obj.payloadContainer()
219  payloads_sz = payloads.size()
220  if hasattr(payloads, 'at'):
221  # HACK for bug #77976
222  _tmp = payloads
223  payloads = []
224  for ii in range(payloads_sz):
225  payloads.append(_tmp.at(ii))
226  pass
227  for ii, payload in zip(range(payloads_sz), payloads):
228  if not payload:
229  msg.info("**error** null-pointer ?")
230  continue
231  # names
232  chan_names = []
233  sz = payload.name_size()
234  for idx in range(sz):
235  chan = payload.chanNum(idx)
236  chan_name = payload.chanName(chan)
237  chan_names.append(chan_name)
238 
239  # iovs
240  sz = payload.iov_size()
241  for idx in range(sz):
242  chan = payload.chanNum(idx)
243  iov_range = payload.iovRange(chan)
244  iov_start = iov_range.start()
245  iov_stop = iov_range.stop()
246  if (idx < 10):
247  msg.info('({}, {}) => ({}, {}) valid={} runEvt={}'.format(
248  iov_start.run(),
249  iov_start.event(),
250  iov_stop.run(),
251  iov_stop.event(),
252  iov_start.isValid(),
253  iov_start.isRunEvent()))
254  elif (idx == 10):
255  msg.info("... {} more".format(sz-9))
256  iovs.append((iov_start.run(), iov_start.event(),
257  iov_stop.run(), iov_stop.event(),
258  iov_start.isValid(), iov_start.isRunEvent(),
259  chan))
260 
261  # attrs
262  attrs = [] # can't use a dict as spec.name() isn't unique
263  sz = payload.size()
264  for idx in range(sz):
265  chan = payload.chanNum(idx)
266  attr_list = payload.attributeList(chan)
267  attr_data = []
268  for a in list(toiter(attr_list.begin(), attr_list.end())):
269  spec = a.specification()
270  a_type = spec.typeName()
271  if a_type.find('string') >= 0:
272  a_data = a.data['string']()
273  try:
274  a_data = eval(a_data, {}, {})
275  except Exception:
276  # swallow and keep as a string
277  pass
278  else:
279  a_data = a.data[a_type]()
280  attr_data.append((spec.name(), a_data))
281  attrs.append(dict(attr_data))
282  if len(attrs) == len(chan_names):
283  data.append(dict(zip(chan_names, attrs)))
284  else:
285  if len(attrs):
286  if len(attrs) == 1:
287  data.append(attrs[0])
288  else:
289  data.append(attrs)
290  else:
291  data.append(chan_names)
292  pass # loop over payloads...
293 
294  return (data, iovs)
295 

◆ reinitialize()

StatusCode PyAthena::Alg::reinitialize ( )
overridevirtualinherited

Definition at line 67 of file PyAthenaAlg.cxx.

68 {
69  ATH_MSG_INFO("Re-Initializing " << name() << "...");
70  return PyAthena::callPyMethod( m_self, "sysReinitialize" );
71 }

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< Algorithm > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ self()

virtual PyObject* PyAthena::Alg::self ( )
inlineoverridevirtualinherited

return associated python object.

BORROWED reference.

Implements IPyComponent.

Definition at line 71 of file PyAthenaAlg.h.

71 { return m_self; }

◆ setPyAttr()

bool PyAthena::Alg::setPyAttr ( PyObject pyobj)
overrideprotectedvirtualinherited

attach the C++ component to its python cousin

Implements IPyComponent.

Definition at line 143 of file PyAthenaAlg.cxx.

144 {
145  // now we tell the PyObject which C++ object it is the cousin of.
147  PyObject* pyobj = TPython::CPPInstance_FromVoidPtr
148  ( (void*)this, this->typeName() );
149  if ( !pyobj ) {
150  PyErr_Clear();
151  // try PyAthena::Alg
152  pyobj = TPython::CPPInstance_FromVoidPtr ((void*)this, "PyAthena::Alg");
154  ("could not dyncast component [" << name() << "] to a python "
155  << "object of type [" << this->typeName() << "] (probably a missing "
156  << "dictionary)" << endmsg
157  << "fallback to [PyAthena::Alg]...");
158  }
159  if ( !pyobj ) {
160  PyErr_Clear();
161  ATH_MSG_WARNING("Could not dyncast component ["
162  << name() << "] to a pyobject of type ["
163  << this->typeName() << "]");
164  } else {
165  if ( -1 == PyObject_SetAttrString(o, "_cppHandle", pyobj) ) {
166  PyErr_Clear();
168  ("Could not attach C++ handle [" << name() << "] to its python "
169  << "cousin !");
170  if ( -1 == PyObject_SetAttrString(o, "_cppHandle", Py_None) ) {
171  PyErr_Clear();
173  ("could not attach a dummy C++ handle [" << name() << "] to its "
174  "python cousin !");
175  }
176  } else {
177  return true;
178  }
179  }
180  return false;
181 }

◆ start() [1/2]

StatusCode PyAthena::Alg::start ( )
overridevirtualinherited

Definition at line 74 of file PyAthenaAlg.cxx.

75 {
76  return PyAthena::callPyMethod( m_self, "sysStart" );
77 }

◆ start() [2/2]

def python.POOL2EI_Lib.POOL2EI.start (   self)

Definition at line 569 of file POOL2EI_Lib.py.

569  def start(self):
570 
571  _info = self.msg.info
572  _info("POOL2EI::start")
573 
574  return StatusCode.Success
575 

◆ stop()

StatusCode PyAthena::Alg::stop ( )
overridevirtualinherited

Definition at line 80 of file PyAthenaAlg.cxx.

81 {
82  return PyAthena::callPyMethod( m_self, "sysStop" );
83 }

◆ sysInitialize()

StatusCode PyAthena::Alg::sysInitialize ( )
overridevirtualinherited

Override sysInitialize.

Override sysInitialize from the base class.

Loop through all output handles, and if they're WriteCondHandles, automatically register them and this Algorithm with the CondSvc

Scan through all outputHandles, and if they're WriteCondHandles, register them with the CondSvc

Reimplemented from AthAlgorithm.

Definition at line 105 of file PyAthenaAlg.cxx.

106 {
108  ( "PyAthena::PyComponentMgr/PyComponentMgr", name() );
109  if ( !pyMgr.retrieve().isSuccess() ) {
110  ATH_MSG_ERROR("Could not retrieve service [" << pyMgr.typeAndName()
111  << "] !!");
112  return StatusCode::FAILURE;
113  }
114 
115  // first retrieve our python object cousin...
116  m_self = pyMgr->pyObject( this );
117 
118  if ( m_self == Py_None ) {
119  ATH_MSG_ERROR("Wrapped PyObject is NONE !");
120  return StatusCode::FAILURE;
121  }
122 
123  // re-route to usual sysInit...
124  return AlgBase_t::sysInitialize();
125 }

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< Algorithm > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ typeName()

const char * PyAthena::Alg::typeName ( ) const
overridevirtualinherited

return the std::type_info name of the underlying py-component This is used by concrete implementations to connect a python component to its C++ counter-part

Implements IPyComponent.

Definition at line 132 of file PyAthenaAlg.cxx.

133 {
134  static const std::string tname = System::typeinfoName(typeid(*this));
135  return tname.c_str();
136 }

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< Algorithm > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ _dsname

python.POOL2EI_Lib.POOL2EI._dsname
private

Definition at line 88 of file POOL2EI_Lib.py.

◆ _dsname_orig

python.POOL2EI_Lib.POOL2EI._dsname_orig
private

Definition at line 117 of file POOL2EI_Lib.py.

◆ _eif

python.POOL2EI_Lib.POOL2EI._eif = None
staticprivate

Definition at line 50 of file POOL2EI_Lib.py.

◆ _eif_entries [1/2]

int python.POOL2EI_Lib.POOL2EI._eif_entries = 0
staticprivate

Definition at line 51 of file POOL2EI_Lib.py.

◆ _eif_entries [2/2]

python.POOL2EI_Lib.POOL2EI._eif_entries
private

Definition at line 305 of file POOL2EI_Lib.py.

◆ _eif_nfiles

int python.POOL2EI_Lib.POOL2EI._eif_nfiles = 0
staticprivate

Definition at line 53 of file POOL2EI_Lib.py.

◆ _eif_spb

python.POOL2EI_Lib.POOL2EI._eif_spb
private

Definition at line 150 of file POOL2EI_Lib.py.

◆ _eif_totentries

int python.POOL2EI_Lib.POOL2EI._eif_totentries = 0
staticprivate

Definition at line 52 of file POOL2EI_Lib.py.

◆ _eifname

python.POOL2EI_Lib.POOL2EI._eifname = None
staticprivate

Definition at line 54 of file POOL2EI_Lib.py.

◆ _eifname_spb

python.POOL2EI_Lib.POOL2EI._eifname_spb = None
staticprivate

Definition at line 55 of file POOL2EI_Lib.py.

◆ _eimagic

int python.POOL2EI_Lib.POOL2EI._eimagic = 0x6e56c8c7
staticprivate

Definition at line 59 of file POOL2EI_Lib.py.

◆ _eiversion

int python.POOL2EI_Lib.POOL2EI._eiversion = 0x00000001
staticprivate

Definition at line 58 of file POOL2EI_Lib.py.

◆ _initialized [1/2]

bool python.POOL2EI_Lib.POOL2EI._initialized = False
staticprivate

Definition at line 56 of file POOL2EI_Lib.py.

◆ _initialized [2/2]

python.POOL2EI_Lib.POOL2EI._initialized
private

Definition at line 191 of file POOL2EI_Lib.py.

◆ _iov

python.POOL2EI_Lib.POOL2EI._iov = IOV()
staticprivate

Definition at line 49 of file POOL2EI_Lib.py.

◆ eipbof

python.POOL2EI_Lib.POOL2EI.eipbof

Definition at line 86 of file POOL2EI_Lib.py.

◆ guid

python.POOL2EI_Lib.POOL2EI.guid

Definition at line 348 of file POOL2EI_Lib.py.

◆ guids

python.POOL2EI_Lib.POOL2EI.guids

Definition at line 346 of file POOL2EI_Lib.py.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_extendedExtraObjects

DataObjIDColl AthAlgorithm::m_extendedExtraObjects
privateinherited

Definition at line 79 of file AthAlgorithm.h.

◆ m_self

PyObject* PyAthena::Alg::m_self
protectedinherited

Pointer to self (from the python world)

Definition at line 96 of file PyAthenaAlg.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< Algorithm > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following file:
PyAthena::Alg::m_self
PyObject * m_self
Pointer to self (from the python world)
Definition: PyAthenaAlg.h:96
python.tests.PyTestsLib.finalize
def finalize(self)
_info( "content of StoreGate..." ) self.sg.dump()
Definition: PyTestsLib.py:50
PyAthena::Alg::typeName
virtual const char * typeName() const override
return the std::type_info name of the underlying py-component This is used by concrete implementation...
Definition: PyAthenaAlg.cxx:132
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
vtune_athena.format
format
Definition: vtune_athena.py:14
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FullCPAlgorithmsTest_eljob.flush
flush
Definition: FullCPAlgorithmsTest_eljob.py:173
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
AthCommonDataStore::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
initialize
void initialize()
Definition: run_EoverP.cxx:894
mergePhysValFiles.start
start
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:14
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
RootUtils::PyGILStateEnsure
Definition: PyAthenaGILStateEnsure.h:20
IDTPMcnv.htype
htype
Definition: IDTPMcnv.py:27
LArG4FSStartPointFilterLegacy.execute
execute
Definition: LArG4FSStartPointFilterLegacy.py:20
AthCommonDataStore
Definition: AthCommonDataStore.h:52
AthAlgorithm::sysInitialize
virtual StatusCode sysInitialize() override
Override sysInitialize.
Definition: AthAlgorithm.cxx:66
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
python.POOL2EI_Lib._import_ROOT
def _import_ROOT()
Definition: POOL2EI_Lib.py:33
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
python.ByteStreamConfig.write
def write
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:248
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
add
bool add(const std::string &hname, TKey *tobj)
Definition: fastadd.cxx:55
histSizes.list
def list(name, path='/')
Definition: histSizes.py:38
AthCommonDataStore< AthCommonMsg< Algorithm > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
xAOD::TriggerMenu
TriggerMenu_v1 TriggerMenu
Define the latest version of the trigger menu class.
Definition: TriggerMenu.h:16
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
createCoolChannelIdFile.par
par
Definition: createCoolChannelIdFile.py:29
python.POOL2EI_Lib.toiter
def toiter(beg, end)
Definition: POOL2EI_Lib.py:39
RTTAlgmain.address
address
Definition: RTTAlgmain.py:55
python.compressB64.compressB64
def compressB64(s)
Definition: compressB64.py:29
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
AthAlgorithm::m_extendedExtraObjects
DataObjIDColl m_extendedExtraObjects
Definition: AthAlgorithm.h:79
a
TList * a
Definition: liststreamerinfos.cxx:10
h
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
get
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
Definition: hcg.cxx:127
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:623
str
Definition: BTagTrackIpAccessor.cxx:11
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
PyObject
_object PyObject
Definition: IPyComponent.h:26
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
Trk::split
@ split
Definition: LayerMaterialProperties.h:38
PixelByteStreamErrors::Trailer
@ Trailer
Definition: PixelByteStreamErrors.h:13
fitman.k
k
Definition: fitman.py:528
ServiceHandle
Definition: ClusterMakerTool.h:37