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

Public Member Functions

def __init__ (self, StreamName, FileName, TreeName=None, asAlg=False)
 
def SetOutputFileName (self, name)
 
def AddItem (self, item)
 
def RemoveItem (self, item)
 
def AddMetaDataItem (self, item)
 
def RemoveMetaDataItem (self, item)
 
def Print (self)
 
def __iadd__ (self, configs)
 
def __getattr__ (self, attr)
 
def __setattr__ (self, name, value)
 
def AddAcceptAlgs (self, algs)
 Accept Algs. More...
 
def RemoveAcceptAlgs (self, algs)
 
def GetAcceptAlgs (self)
 
def AddRequireAlgs (self, algs)
 Require Algs. More...
 
def RemoveRequireAlgs (self, algs)
 
def GetRequireAlgs (self)
 
def AddVetoAlgs (self, algs)
 Veto Algs (ignored by prescaler for now) More...
 
def RemoveVetoAlgs (self, algs)
 
def GetVetoAlgs (self)
 
def AddOtherAlgsToBookkeep (self, algs)
 Other Algs (e.g. More...
 
def RemoveOtherAlgsToBookkeep (self, algs)
 
def GetOtherAlgsToBookkeep (self)
 
def GetSkimDecisionsWriter (self)
 Skim decisions writer. More...
 
def SetPrescale (self, value)
 Master prescale. More...
 
def GetPrescale (self)
 

Public Attributes

 fileName
 
 treeName
 
 Stream
 
 filterSeq
 
 Name
 
 OtherAlgs
 

Private Member Functions

def _ItemInList (self, item, aList)
 
def _AddValidItemToList (self, item, aList)
 
def _RemoveValidItemFromList (self, item, aList)
 

Private Attributes

 _Prescaler
 

Detailed Description

This class is used to handle output ROOT (D3PD) streams in Athena.
   It inherits from the AugmentedStreamBase class, so implements its
   interface, but at the same time it behaves for all intents and
   purposes like a configurable for the D3PD::MakerAlg class.

Definition at line 375 of file MultipleStreamManager.py.

Constructor & Destructor Documentation

◆ __init__()

def python.MultipleStreamManager.AugmentedRootStream.__init__ (   self,
  StreamName,
  FileName,
  TreeName = None,
  asAlg = False 
)
Constructor for the D3PD stream object.

   Arguments:
      StreamName: Logical name of the D3PD stream. Note that beside
          using it to define the stream in THistSvc, this
          name is also used as the name of the TTree in the
          output file in case one is not specified explicitly.
      FileName: Name of the file to write the D3PD TTree into.
      TreeName: Name of the TTree in the output file. If it's not
        specified, the stream name is used as the tree name.
      asAlg: If set to True, the D3PD::MakerAlg algorithm is added
     to the job as a regular algorithm. When set to False
     (default), the D3PD algorithm is added to the application
     manager as an output stream.

Definition at line 381 of file MultipleStreamManager.py.

381  def __init__( self, StreamName, FileName, TreeName = None, asAlg = False ):
382  """Constructor for the D3PD stream object.
383 
384  Arguments:
385  StreamName: Logical name of the D3PD stream. Note that beside
386  using it to define the stream in THistSvc, this
387  name is also used as the name of the TTree in the
388  output file in case one is not specified explicitly.
389  FileName: Name of the file to write the D3PD TTree into.
390  TreeName: Name of the TTree in the output file. If it's not
391  specified, the stream name is used as the tree name.
392  asAlg: If set to True, the D3PD::MakerAlg algorithm is added
393  to the job as a regular algorithm. When set to False
394  (default), the D3PD algorithm is added to the application
395  manager as an output stream.
396  """
397  # Initialize the base class:
398  AugmentedStreamBase.__init__( self, StreamName )
399 
400  # Check if the user specified a tree name or not:
401  if TreeName is None:
402  TreeName = StreamName
403 
404  # Remember the file and tree names just for bookkeeping:
405  self.fileName = FileName
406  self.treeName = TreeName
407 
408  # We need to add some stuff to the main algorithm sequence:
409  from AthenaCommon.AlgSequence import AlgSequence
410  topSequence = AlgSequence()
411 
412  # Create a sequence where the pre-D3PD-making algorithms are run:
413  from D3PDMakerConfig.D3PDMakerFlags import D3PDMakerFlags
414  preseq = AlgSequence( D3PDMakerFlags.PreD3PDAlgSeqName(),
415  StopOverride = True )
416  if not hasattr( topSequence, D3PDMakerFlags.PreD3PDAlgSeqName() ):
417  topSequence += [ preseq ]
418  pass
419 
420 
421  # Add the AANT algorithm for making it possible to back navigate
422  # from D3PD events:
423  ParentStreamName = StreamName.split( ':' )[ 0 ]
424  if StreamName.count( ':' ) != 0:
425  if StreamName.count( ':' ) == 1:
426  StreamName = StreamName.split( ':' )[ 1 ]
427  else:
428  raise AttributeError( "Stream name '%s' can't be used!" % StreamName )
429  if not hasattr( topSequence, ParentStreamName + "AANTStream" ):
430  try:
431  from AnalysisTools.AnalysisToolsConf import AANTupleStream
432  topSequence += AANTupleStream( ParentStreamName + "AANTStream",
433  ExtraRefNames = ['StreamRDO',
434  'StreamRAW',
435  'StreamESD',
436  'StreamAOD'],
437  OutputName = FileName,
438  WriteInputDataHeader = True,
439  StreamName = ParentStreamName )
440  pass
441  except ImportError:
442  print(self.Name,": INFO didn't find AnalysisTools.AnalysisToolsConf in release.")
443  import traceback
444  print(traceback.format_exc())
445  pass
446 
447  # Make sure that THistSvc exists.
448  from AthenaCommon.AppMgr import ServiceMgr
449  if not hasattr( ServiceMgr, 'THistSvc' ):
450  from GaudiSvc.GaudiSvcConf import THistSvc
451  ServiceMgr += THistSvc()
452 
453  # Check if the requested stream is already defined in THistSvc:
454  streamExists = False
455  for s in ServiceMgr.THistSvc.Output:
456  stream = s.split()[ 0 ]
457  if stream == StreamName:
458  streamExists = True
459  break
460 
461  # Add the stream if it's not defined yet:
462  if not streamExists:
463  ServiceMgr.THistSvc.Output += [ "%s DATAFILE='%s' OPT='RECREATE' CL='%i'" %
464  ( StreamName, FileName,
465  D3PDMakerFlags.CompressionLevel() ) ]
466 
467  # Finally, create the D3PD::MakerAlg algorithm and add it to the job.
468  # Note that here we're specifying that the D3PDMaker code should use
469  # ROOT output.
470  #
471  # If we're adding as an algorithm directly, then pass the parent sequence
472  # into MakerAlg(...). MakerAlg(...) will then add itself to the sequence
473  # and also set up the accompanying filter sequence. Otherwise, we add it
474  # as a stream; in that case we set up backwards compatibility for
475  # 'filterSeq'.
476  try:
477  import D3PDMakerCoreComps
478  if asAlg:
479  theseq = topSequence
480  else:
481  theseq = None
482  pass
483  self.Stream = D3PDMakerCoreComps.MakerAlg( StreamName + "D3PDMaker", seq = theseq,
484  file = FileName, stream = ParentStreamName,
485  tuplename = TreeName,
486  D3PDSvc = "D3PD::RootD3PDSvc" )
487 
488  if not asAlg:
489  from AthenaCommon.AppMgr import theApp
490  theApp.addOutputStream( self.Stream )
491  # Backwards compatibility for the filter algoirthm:
492  self.filterSeq = _RootStreamFilterHelper( self, topSequence )
493  pass
494  pass
495  except ImportError:
496  print(self.Name,": INFO didn't find D3PDMakerCoreComps in release.")
497  pass
498 
499  return
500 

Member Function Documentation

◆ __getattr__()

def python.MultipleStreamManager.AugmentedRootStream.__getattr__ (   self,
  attr 
)
This function forwards attribute requests which don't exist in this object to
   the D3PDMakerCoreComps.MakerAlg object.

Definition at line 543 of file MultipleStreamManager.py.

543  def __getattr__( self, attr ):
544  """This function forwards attribute requests which don't exist in this object to
545  the D3PDMakerCoreComps.MakerAlg object.
546  """
547  if 'Stream' in self.__dict__ and hasattr( self.Stream, attr ):
548  return getattr( self.Stream, attr )
549  raise AttributeError( "D3PD Maker algorithm doesn't have property '%s'." % attr )
550  return
551 

◆ __iadd__()

def python.MultipleStreamManager.AugmentedRootStream.__iadd__ (   self,
  configs 
)
This function makes it possible to add D3PDObject-s to this object in the same
   way as they are added to D3PDMakerCoreComps.MakerAlg objects..__setattr__( name, value )

Definition at line 536 of file MultipleStreamManager.py.

536  def __iadd__( self, configs ):
537  """This function makes it possible to add D3PDObject-s to this object in the same
538  way as they are added to D3PDMakerCoreComps.MakerAlg objects..__setattr__( name, value )
539  """
540  self.Stream += configs
541  return self
542 

◆ __setattr__()

def python.MultipleStreamManager.AugmentedRootStream.__setattr__ (   self,
  name,
  value 
)
This function forwards attribute setting requests to the D3PDMakerCoreComps.MakerAlg
   object.

Definition at line 552 of file MultipleStreamManager.py.

552  def __setattr__( self, name, value ):
553  """This function forwards attribute setting requests to the D3PDMakerCoreComps.MakerAlg
554  object.
555  """
556  if hasattr( self, "Stream" ):
557  if hasattr( self.Stream, name ):
558  return self.Stream.__setattr__( name, value )
559  # The following doesn't work... :-/
560  # super( AugmentedRootStream, self ).__setattr__( name, value )
561  # So instead I'm using this:
562  self.__dict__[ name ] = value
563  return
564 

◆ _AddValidItemToList()

def python.MultipleStreamManager.AugmentedStreamBase._AddValidItemToList (   self,
  item,
  aList 
)
privateinherited

Definition at line 35 of file MultipleStreamManager.py.

35  def _AddValidItemToList(self,item,aList):
36  #Recursive loop if item is a list
37  if isinstance(item,list):
38  for i in item:
39  self._AddValidItemToList(i,aList)
40  #Add to list if item is a string and not already in the list
41  elif isinstance(item, str):
42  if not self._ItemInList(item,aList):
43  aList += [item]
44  else:
45  raise TypeError("AugmentedPoolStream._AddValidItemToList() does not support item of type %s"%type(item))
46  return
47 

◆ _ItemInList()

def python.MultipleStreamManager.AugmentedStreamBase._ItemInList (   self,
  item,
  aList 
)
privateinherited

Definition at line 24 of file MultipleStreamManager.py.

24  def _ItemInList(self,item,aList):
25  #Make sure aList is a list
26  if not isinstance(aList, list):
27  raise TypeError("AugmentedPoolStream._ItemInList() does not support aList of type %s"%type(aList))
28 
29  isInList=False
30  for i in aList:
31  if i==item:
32  isInList=True
33  return isInList
34 

◆ _RemoveValidItemFromList()

def python.MultipleStreamManager.AugmentedStreamBase._RemoveValidItemFromList (   self,
  item,
  aList 
)
privateinherited

Definition at line 48 of file MultipleStreamManager.py.

48  def _RemoveValidItemFromList(self,item,aList):
49  #Recursive loop if item is a list
50  if isinstance(item,list):
51  for i in item:
52  self._RemoveValidItemFromList(i,aList)
53  #Remove from list if item is a string and already in list
54  elif isinstance(item, str):
55  if self._ItemInList(item,aList):
56  aList.remove(item)
57  else:
58  print(self.Name,": WARNING you asked to remove item '%s' but this item is not present",item)
59  else:
60  raise TypeError("AugmentedPoolStream._RemoveValidItemFromList() does not support item of type %s"%type(item))
61  return
62 

◆ AddAcceptAlgs()

def python.MultipleStreamManager.AugmentedStreamBase.AddAcceptAlgs (   self,
  algs 
)
inherited

Accept Algs.

Definition at line 65 of file MultipleStreamManager.py.

65  def AddAcceptAlgs(self, algs):
66  self._AddValidItemToList(algs, self.Stream.AcceptAlgs)
67  return
68 

◆ AddItem()

def python.MultipleStreamManager.AugmentedRootStream.AddItem (   self,
  item 
)

Definition at line 511 of file MultipleStreamManager.py.

511  def AddItem(self, item): pass

◆ AddMetaDataItem()

def python.MultipleStreamManager.AugmentedRootStream.AddMetaDataItem (   self,
  item 
)

Definition at line 513 of file MultipleStreamManager.py.

513  def AddMetaDataItem(self, item): pass

◆ AddOtherAlgsToBookkeep()

def python.MultipleStreamManager.AugmentedStreamBase.AddOtherAlgsToBookkeep (   self,
  algs 
)
inherited

Other Algs (e.g.

those used by a FilterCombiner, but ignored by everybody else)

Definition at line 104 of file MultipleStreamManager.py.

104  def AddOtherAlgsToBookkeep(self, algs):
105  self._AddValidItemToList(algs, self.OtherAlgs)
106  return
107 

◆ AddRequireAlgs()

def python.MultipleStreamManager.AugmentedStreamBase.AddRequireAlgs (   self,
  algs 
)
inherited

Require Algs.

Definition at line 78 of file MultipleStreamManager.py.

78  def AddRequireAlgs(self, algs):
79  self._AddValidItemToList(algs, self.Stream.RequireAlgs)
80  return
81 

◆ AddVetoAlgs()

def python.MultipleStreamManager.AugmentedStreamBase.AddVetoAlgs (   self,
  algs 
)
inherited

Veto Algs (ignored by prescaler for now)

Definition at line 91 of file MultipleStreamManager.py.

91  def AddVetoAlgs(self, algs):
92  self._AddValidItemToList(algs, self.Stream.VetoAlgs)
93  return
94 

◆ GetAcceptAlgs()

def python.MultipleStreamManager.AugmentedStreamBase.GetAcceptAlgs (   self)
inherited

Definition at line 73 of file MultipleStreamManager.py.

73  def GetAcceptAlgs(self):
74  return self.Stream.AcceptAlgs
75 

◆ GetOtherAlgsToBookkeep()

def python.MultipleStreamManager.AugmentedStreamBase.GetOtherAlgsToBookkeep (   self)
inherited

Definition at line 112 of file MultipleStreamManager.py.

112  def GetOtherAlgsToBookkeep(self):
113  return self.OtherAlgs
114 

◆ GetPrescale()

def python.MultipleStreamManager.AugmentedStreamBase.GetPrescale (   self)
inherited

Definition at line 156 of file MultipleStreamManager.py.

156  def GetPrescale(self):
157  if hasattr(self,"_Prescaler"):
158  return self._Prescaler.Prescale
159  else:
160  return "NONE"
161 
162 
163 

◆ GetRequireAlgs()

def python.MultipleStreamManager.AugmentedStreamBase.GetRequireAlgs (   self)
inherited

Definition at line 86 of file MultipleStreamManager.py.

86  def GetRequireAlgs(self):
87  return self.Stream.RequireAlgs
88 

◆ GetSkimDecisionsWriter()

def python.MultipleStreamManager.AugmentedStreamBase.GetSkimDecisionsWriter (   self)
inherited

Skim decisions writer.

Definition at line 117 of file MultipleStreamManager.py.

117  def GetSkimDecisionsWriter(self):
118  from EventBookkeeperTools.BookkeepingInfoWriter import SkimDecisionsWriter
119  sdw=SkimDecisionsWriter(self.Name+"_SkimDecisionsWriter")
120  newContainerName=self.Name+"_"+sdw.SkimDecisionsContainerName
121  sdw.SkimDecisionsContainerName=newContainerName
122  #sdw.OutputLevel=2
123  for a in self.GetRequireAlgs():
124  sdw.addRequireAlg(a)
125  for a in self.GetAcceptAlgs():
126  sdw.addAcceptAlg(a)
127  for a in self.GetVetoAlgs():
128  sdw.addVetoAlg(a)
129  for a in self.GetOtherAlgsToBookkeep():
130  sdw.addOtherAlg(a)
131  return sdw
132 

◆ GetVetoAlgs()

def python.MultipleStreamManager.AugmentedStreamBase.GetVetoAlgs (   self)
inherited

Definition at line 99 of file MultipleStreamManager.py.

99  def GetVetoAlgs(self):
100  return self.Stream.VetoAlgs
101 

◆ Print()

def python.MultipleStreamManager.AugmentedRootStream.Print (   self)

Definition at line 516 of file MultipleStreamManager.py.

516  def Print(self):
517  print("**** AugmentedRootStream",self.Name,"****")
518  print("Output file:")
519  print(" " + self.fileName)
520  print("TTree name:")
521  print(" " + self.treeName)
522  print("AcceptAlgs:")
523  print(" " + str( self.Stream.AcceptAlgs ))
524  print("RequireAlgs:")
525  print(" " + str( self.Stream.RequireAlgs ))
526  print("VetoAlgs:")
527  print(" " + str( self.Stream.VetoAlgs ))
528  print("OtherAlgs to bookkeep (but not directly used by the Stream):")
529  print(" " + str( self.OtherAlgs ))
530  print("Master prescale:")
531  print(" " + str( self.GetPrescale() ))
532  print("ItemList:")
533  print(" Not available for ROOT (D3PD) stream")
534  return
535 

◆ RemoveAcceptAlgs()

def python.MultipleStreamManager.AugmentedStreamBase.RemoveAcceptAlgs (   self,
  algs 
)
inherited

Definition at line 69 of file MultipleStreamManager.py.

69  def RemoveAcceptAlgs(self, algs):
70  self._RemoveValidItemFromList(algs, self.Stream.AcceptAlgs)
71  return
72 

◆ RemoveItem()

def python.MultipleStreamManager.AugmentedRootStream.RemoveItem (   self,
  item 
)

Definition at line 512 of file MultipleStreamManager.py.

512  def RemoveItem(self, item): pass

◆ RemoveMetaDataItem()

def python.MultipleStreamManager.AugmentedRootStream.RemoveMetaDataItem (   self,
  item 
)

Definition at line 514 of file MultipleStreamManager.py.

514  def RemoveMetaDataItem(self, item): pass
515 

◆ RemoveOtherAlgsToBookkeep()

def python.MultipleStreamManager.AugmentedStreamBase.RemoveOtherAlgsToBookkeep (   self,
  algs 
)
inherited

Definition at line 108 of file MultipleStreamManager.py.

108  def RemoveOtherAlgsToBookkeep(self, algs):
109  self._RemoveValidItemFromList(algs, self.OtherAlgs)
110  return
111 

◆ RemoveRequireAlgs()

def python.MultipleStreamManager.AugmentedStreamBase.RemoveRequireAlgs (   self,
  algs 
)
inherited

Definition at line 82 of file MultipleStreamManager.py.

82  def RemoveRequireAlgs(self, algs):
83  self._RemoveValidItemFromList(algs, self.Stream.RequireAlgs)
84  return
85 

◆ RemoveVetoAlgs()

def python.MultipleStreamManager.AugmentedStreamBase.RemoveVetoAlgs (   self,
  algs 
)
inherited

Definition at line 95 of file MultipleStreamManager.py.

95  def RemoveVetoAlgs(self, algs):
96  self._RemoveValidItemFromList(algs, self.Stream.VetoAlgs)
97  return
98 

◆ SetOutputFileName()

def python.MultipleStreamManager.AugmentedRootStream.SetOutputFileName (   self,
  name 
)
It's not impossible to change the file name after the stream has been created,
   but I didn't want to write this code unless there's actual need for it.

Definition at line 501 of file MultipleStreamManager.py.

501  def SetOutputFileName(self, name):
502  """It's not impossible to change the file name after the stream has been created,
503  but I didn't want to write this code unless there's actual need for it.
504  """
505  print("**** ERROR: Can't change the name of the output ROOT file! ****")
506  return
507 

◆ SetPrescale()

def python.MultipleStreamManager.AugmentedStreamBase.SetPrescale (   self,
  value 
)
inherited

Master prescale.

Definition at line 135 of file MultipleStreamManager.py.

135  def SetPrescale(self,value):
136  #Set a master prescale to given value. Create the Prescaler tool if necessary.
137  if not hasattr(self,"_Prescaler"):
138  from PrimaryDPDMaker.PrimaryDPDMakerConf import PrimaryDPDPrescaler
139  prescalerName="MasterPrescale_"+self.Name
140  self._Prescaler = PrimaryDPDPrescaler(prescalerName)
141  #Deep copies of the Require and Accept algs lists considered by the Master prescaler
142  #Notes:
143  # 1) deep copy is necessary because the Master prescaler itself will be added to the RequireAlgs list\
144  # 2) this implies that SetPrescale must be the *last* algorithm added to the stream
145  self._Prescaler.RequireAlgs = self.Stream.RequireAlgs[:]
146  self._Prescaler.AcceptAlgs = self.Stream.AcceptAlgs[:]
147 
148  from AthenaCommon.AlgSequence import AlgSequence
149  topSequence = AlgSequence()
150  topSequence += self._Prescaler
151  self.AddRequireAlgs(prescalerName)
152 
153  self._Prescaler.Prescale=value
154  return
155 

Member Data Documentation

◆ _Prescaler

python.MultipleStreamManager.AugmentedStreamBase._Prescaler
privateinherited

Definition at line 140 of file MultipleStreamManager.py.

◆ fileName

python.MultipleStreamManager.AugmentedRootStream.fileName

Definition at line 405 of file MultipleStreamManager.py.

◆ filterSeq

python.MultipleStreamManager.AugmentedRootStream.filterSeq

Definition at line 492 of file MultipleStreamManager.py.

◆ Name

python.MultipleStreamManager.AugmentedStreamBase.Name
inherited

Definition at line 14 of file MultipleStreamManager.py.

◆ OtherAlgs

python.MultipleStreamManager.AugmentedStreamBase.OtherAlgs
inherited

Definition at line 15 of file MultipleStreamManager.py.

◆ Stream

python.MultipleStreamManager.AugmentedRootStream.Stream

Definition at line 483 of file MultipleStreamManager.py.

◆ treeName

python.MultipleStreamManager.AugmentedRootStream.treeName

Definition at line 406 of file MultipleStreamManager.py.


The documentation for this class was generated from the following file:
python.AlgSequence.AlgSequence
AlgSequence
Definition: PhysicsAnalysis/D3PDTools/AnaAlgorithm/python/AlgSequence.py:7
PrimaryDPDPrescaler
Definition: PrimaryDPDPrescaler.h:17
AANTupleStream
Definition: AANTupleStream.h:35
Lb2Lll.THistSvc
THistSvc
Definition: Lb2Lll.py:216
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
Muon::print
std::string print(const MuPatSegment &)
Definition: MuonTrackSteering.cxx:28
dqm_persistency::Print
void Print(const PParameter *param, TDirectory *topdir, Option_t *opt="")
Definition: dqm_persistency_impl.cxx:161
str
Definition: BTagTrackIpAccessor.cxx:11
python.PyAthenaComps.__setattr__
__setattr__
Definition: PyAthenaComps.py:41