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

Public Member Functions

def __init__ (self, top_level_algorithm='WorstCaseSummary')
 
def addOutput (self, name, algorithm, annotations={}, attributes={})
 
def getAlgorithm (self, name)
 
def getReference (self, name)
 
def addSubDir (self, name)
 
def addHistogram (self, histogram, algorithm, annotations={}, output=DQHanConfMaker._default_output, attributes={})
 
def getSubDir (self, name)
 
def tohan (self, encoding=None)
 
def toprettyhan (self, indent="\t", newl="\n", encoding=None)
 
def writehan (self, writer, indent="", addindent="", newl="")
 
def appendChild (self, child)
 
def setAttribute (self, key, attribute)
 
def removeAttribute (self, key)
 
def getAttribute (self, key)
 
def getSubNode (self, name, nodetype)
 
def __str__ (self)
 
def getAlgorithm (self)
 
def getOutputPath (self, append=None, delimiter="/")
 
def tohan (self, encoding=None)
 
def toprettyhan (self, indent="\t", newl="\n", encoding=None)
 
def writehan (self, writer, indent="", addindent="", newl="")
 
def appendChild (self, child)
 
def setAttribute (self, key, attribute)
 
def removeAttribute (self, key)
 
def getAttribute (self, key)
 
def getSubNode (self, name, nodetype)
 
def __str__ (self)
 

Public Attributes

 nodeType
 
 acceptChild
 
 root_output_level
 
 subnodes
 
 attributes
 
 name
 
 father
 
 subnodes
 
 attributes
 
 name
 

Detailed Description

Class representing a han document

Definition at line 509 of file hanwriter.py.

Constructor & Destructor Documentation

◆ __init__()

def python.hanwriter.Document.__init__ (   self,
  top_level_algorithm = 'WorstCaseSummary' 
)
Creates an empty han document with a top level output

Reimplemented from python.hanwriter.HanDir.

Definition at line 516 of file hanwriter.py.

516  def __init__(self, top_level_algorithm='WorstCaseSummary'):
517  """
518  Creates an empty han document with a top level output
519  """
520  HanDir.__init__(self, '')
521  HanOutput.__init__(self, '')
522  self.nodeType = Node.DOCUMENT
523  self.acceptChild = [Node.ALGORITHM, Node.DIR, Node.HIST, Node.OUTPUT, Node.REFERENCE, Node.THRESHOLD,
524  Node.COMPALG]
525  self.root_output_level = HanOutput('top_level', top_level_algorithm)
526  self.appendChild(self.root_output_level)

Member Function Documentation

◆ __str__() [1/2]

def python.hanwriter.Node.__str__ (   self)
inherited

Definition at line 190 of file hanwriter.py.

190  def __str__(self):
191  return "HanNode: "+self.name+" ("+DQHanConfMaker._get_NodeType(self.nodeType)+") Attributes:"+str(self.attributes)+" SubNodes: "+str(self.subnodes)
192 
193 
194 # HanHistogram class
195 # This class represents the configuration for a histogram

◆ __str__() [2/2]

def python.hanwriter.Node.__str__ (   self)
inherited

Definition at line 190 of file hanwriter.py.

190  def __str__(self):
191  return "HanNode: "+self.name+" ("+DQHanConfMaker._get_NodeType(self.nodeType)+") Attributes:"+str(self.attributes)+" SubNodes: "+str(self.subnodes)
192 
193 
194 # HanHistogram class
195 # This class represents the configuration for a histogram

◆ addHistogram()

def python.hanwriter.HanDir.addHistogram (   self,
  histogram,
  algorithm,
  annotations = {},
  output = DQHanConfMaker._default_output,
  attributes = {} 
)
inherited
Adds to the directory a histogram specifying the histogram name, the algorithm and the output path.

Definition at line 416 of file hanwriter.py.

416  def addHistogram(self, histogram, algorithm, annotations={}, output=DQHanConfMaker._default_output, attributes={}):
417  """
418  Adds to the directory a histogram specifying the histogram name, the algorithm and the output path.
419  """
420  histo = HanHistogram(histogram, algorithm,
421  annotations, output, attributes)
422  self.appendChild(histo)
423  return histo

◆ addOutput()

def python.hanwriter.Document.addOutput (   self,
  name,
  algorithm,
  annotations = {},
  attributes = {} 
)
Adds a sub output element with name and algorithm

Reimplemented from python.hanwriter.HanOutput.

Definition at line 534 of file hanwriter.py.

534  def addOutput(self, name, algorithm, annotations={}, attributes={}):
535  """
536  Adds a sub output element with name and algorithm
537  """
538  # forward to root region
539  return HanOutput.addOutput(self.root_output_level, name, algorithm, annotations, attributes)

◆ addSubDir()

def python.hanwriter.HanDir.addSubDir (   self,
  name 
)
inherited
Adds a subdirectory called name to the current directory and returns the newly created sub directory

Definition at line 401 of file hanwriter.py.

401  def addSubDir(self, name):
402  """
403  Adds a subdirectory called name to the current directory and returns the newly created sub directory
404  """
405  subdir = HanDir(name)
406  self.appendChild(subdir)
407  return subdir

◆ appendChild() [1/2]

def python.hanwriter.Node.appendChild (   self,
  child 
)
inherited
Add a sub node to this node

Definition at line 126 of file hanwriter.py.

126  def appendChild(self, child):
127  """
128  Add a sub node to this node
129  """
130  try:
131  if child.nodeType not in self.acceptChild:
132  msg = " Node: "+DQHanConfMaker._get_NodeType(self.nodeType)
133  msg += " Cannot have a child of type:", child.nodeType
134  raise HanCannotCreateConf(msg)
135  except Exception:
136  raise HanCannotCreateConf(
137  "Object:"+str(child)+" is not a valid Node")
138  if not self.subnodes:
139  self.subnodes = []
140  self.subnodes += [child]
141 

◆ appendChild() [2/2]

def python.hanwriter.Node.appendChild (   self,
  child 
)
inherited
Add a sub node to this node

Definition at line 126 of file hanwriter.py.

126  def appendChild(self, child):
127  """
128  Add a sub node to this node
129  """
130  try:
131  if child.nodeType not in self.acceptChild:
132  msg = " Node: "+DQHanConfMaker._get_NodeType(self.nodeType)
133  msg += " Cannot have a child of type:", child.nodeType
134  raise HanCannotCreateConf(msg)
135  except Exception:
136  raise HanCannotCreateConf(
137  "Object:"+str(child)+" is not a valid Node")
138  if not self.subnodes:
139  self.subnodes = []
140  self.subnodes += [child]
141 

◆ getAlgorithm() [1/2]

def python.hanwriter.HanOutput.getAlgorithm (   self)
inherited
Gets the algorithm attribute

Definition at line 468 of file hanwriter.py.

468  def getAlgorithm(self):
469  """
470  Gets the algorithm attribute
471  """
472  if 'algorithm' in self.attributes:
473  return self.getAttribute('algorithm')

◆ getAlgorithm() [2/2]

def python.hanwriter.Document.getAlgorithm (   self,
  name 
)
retrieves the algorithm han object associated with name

Definition at line 544 of file hanwriter.py.

544  def getAlgorithm(self, name):
545  """
546  retrieves the algorithm han object associated with name
547  """
548  return self.getSubNode(name, Node.ALGORITHM)

◆ getAttribute() [1/2]

def python.hanwriter.Node.getAttribute (   self,
  key 
)
inherited
Gets the attribute identified by the key, None if not found

Definition at line 168 of file hanwriter.py.

168  def getAttribute(self, key):
169  """
170  Gets the attribute identified by the key, None if not found
171  """
172  if self.attributes and key in self.attributes:
173  return self.attributes[key]
174  return None

◆ getAttribute() [2/2]

def python.hanwriter.Node.getAttribute (   self,
  key 
)
inherited
Gets the attribute identified by the key, None if not found

Definition at line 168 of file hanwriter.py.

168  def getAttribute(self, key):
169  """
170  Gets the attribute identified by the key, None if not found
171  """
172  if self.attributes and key in self.attributes:
173  return self.attributes[key]
174  return None

◆ getOutputPath()

def python.hanwriter.HanOutput.getOutputPath (   self,
  append = None,
  delimiter = "/" 
)
inherited
Creates the complete path of this output directory

Definition at line 493 of file hanwriter.py.

493  def getOutputPath(self, append=None, delimiter="/"):
494  """
495  Creates the complete path of this output directory
496  """
497  name = self.name
498  if append:
499  name = name + append
500  if self.father:
501  name = self.father.getOutputPath(delimiter+name, delimiter)
502  return name
503 
504 # Class document
505 # This class represents the han document.
506 # This class is a set of nodes
507 
508 

◆ getReference()

def python.hanwriter.Document.getReference (   self,
  name 
)
retrieves the han reference associated with name

Definition at line 553 of file hanwriter.py.

553  def getReference(self, name):
554  """
555  retrieves the han reference associated with name
556  """
557  return self.getSubNode(name, Node.REFERENCE)
558 
559 
560 # Add a DQParameter object to the HanDocument
561 # @param handocument: the document containing the configuration @c handocument: a HanDocument object
562 # @param dqparameter: the DQParameter object @c dqparameter: a DQParameter object
563 # @param output: the output element for the result
564 # @note: This function is used internally and should not be used by users of this module

◆ getSubDir()

def python.hanwriter.HanDir.getSubDir (   self,
  name 
)
inherited
returns the sub-directory called name

Definition at line 427 of file hanwriter.py.

427  def getSubDir(self, name):
428  """
429  returns the sub-directory called name
430  """
431  return self.getSubNode(name, Node.DIR)
432 
433 # Class for han output
434 # This class implements the han output
435 
436 

◆ getSubNode() [1/2]

def python.hanwriter.Node.getSubNode (   self,
  name,
  nodetype 
)
inherited
Returns the sub-node identified by name and nodetype

Definition at line 180 of file hanwriter.py.

180  def getSubNode(self, name, nodetype):
181  """
182  Returns the sub-node identified by name and nodetype
183  """
184  if self.subnodes:
185  for sn in self.subnodes:
186  if sn.nodeType == nodetype and sn.name == name:
187  return sn
188  return None
189 

◆ getSubNode() [2/2]

def python.hanwriter.Node.getSubNode (   self,
  name,
  nodetype 
)
inherited
Returns the sub-node identified by name and nodetype

Definition at line 180 of file hanwriter.py.

180  def getSubNode(self, name, nodetype):
181  """
182  Returns the sub-node identified by name and nodetype
183  """
184  if self.subnodes:
185  for sn in self.subnodes:
186  if sn.nodeType == nodetype and sn.name == name:
187  return sn
188  return None
189 

◆ removeAttribute() [1/2]

def python.hanwriter.Node.removeAttribute (   self,
  key 
)
inherited
Removes attribute identified by key

Definition at line 156 of file hanwriter.py.

156  def removeAttribute(self, key):
157  """
158  Removes attribute identified by key
159  """
160  if self.attributes and key in self.attributes:
161  del self.attributes[key]
162  return True
163  return False

◆ removeAttribute() [2/2]

def python.hanwriter.Node.removeAttribute (   self,
  key 
)
inherited
Removes attribute identified by key

Definition at line 156 of file hanwriter.py.

156  def removeAttribute(self, key):
157  """
158  Removes attribute identified by key
159  """
160  if self.attributes and key in self.attributes:
161  del self.attributes[key]
162  return True
163  return False

◆ setAttribute() [1/2]

def python.hanwriter.Node.setAttribute (   self,
  key,
  attribute 
)
inherited
The attribute identified by key is added to this node

Definition at line 145 of file hanwriter.py.

145  def setAttribute(self, key, attribute):
146  """
147  The attribute identified by key is added to this node
148  """
149  if not self.attributes:
150  self.attributes = {}
151  self.attributes[key] = attribute

◆ setAttribute() [2/2]

def python.hanwriter.Node.setAttribute (   self,
  key,
  attribute 
)
inherited
The attribute identified by key is added to this node

Definition at line 145 of file hanwriter.py.

145  def setAttribute(self, key, attribute):
146  """
147  The attribute identified by key is added to this node
148  """
149  if not self.attributes:
150  self.attributes = {}
151  self.attributes[key] = attribute

◆ tohan() [1/2]

def python.hanwriter.Node.tohan (   self,
  encoding = None 
)
inherited
convert the object in a valid han script block

Definition at line 75 of file hanwriter.py.

75  def tohan(self, encoding=None):
76  """
77  convert the object in a valid han script block
78  """
79  return self.toprettyhan("", "", encoding)
80 

◆ tohan() [2/2]

def python.hanwriter.Node.tohan (   self,
  encoding = None 
)
inherited
convert the object in a valid han script block

Definition at line 75 of file hanwriter.py.

75  def tohan(self, encoding=None):
76  """
77  convert the object in a valid han script block
78  """
79  return self.toprettyhan("", "", encoding)
80 

◆ toprettyhan() [1/2]

def python.hanwriter.Node.toprettyhan (   self,
  indent = "\t",
  newl = "\n",
  encoding = None 
)
inherited
convert the object in a formatted han string

Definition at line 86 of file hanwriter.py.

86  def toprettyhan(self, indent="\t", newl="\n", encoding=None):
87  """
88  convert the object in a formatted han string
89  """
90  # restore the following in a future tdaq release
91  # writer = DQHanConfMaker._get_StringIO()
92  import io
93  writer = io.StringIO()
94  if encoding is not None:
95  import codecs
96  writer = codecs.lookup(encoding)[3](writer)
97  self.writehan(writer, "", indent, newl)
98  return writer.getvalue()
99 

◆ toprettyhan() [2/2]

def python.hanwriter.Node.toprettyhan (   self,
  indent = "\t",
  newl = "\n",
  encoding = None 
)
inherited
convert the object in a formatted han string

Definition at line 86 of file hanwriter.py.

86  def toprettyhan(self, indent="\t", newl="\n", encoding=None):
87  """
88  convert the object in a formatted han string
89  """
90  # restore the following in a future tdaq release
91  # writer = DQHanConfMaker._get_StringIO()
92  import io
93  writer = io.StringIO()
94  if encoding is not None:
95  import codecs
96  writer = codecs.lookup(encoding)[3](writer)
97  self.writehan(writer, "", indent, newl)
98  return writer.getvalue()
99 

◆ writehan() [1/2]

def python.hanwriter.Node.writehan (   self,
  writer,
  indent = "",
  addindent = "",
  newl = "" 
)
inherited
Converts the object in a han string and writes it in the writer object

Definition at line 105 of file hanwriter.py.

105  def writehan(self, writer, indent="", addindent="", newl=""):
106  """
107  Converts the object in a han string and writes it in the writer object
108  """
109  writer.write(
110  indent+DQHanConfMaker._get_NodeType(self.nodeType)+" "+self.name)
111  # if it is a document do not need to add { }
112  if self.nodeType != Node.DOCUMENT:
113  writer.write(" { %s" % (newl))
114  if self.attributes:
115  for key, attribute in self.attributes.items():
116  writer.write("%s %s = %s%s" % (indent, key, attribute, newl))
117  if self.subnodes:
118  for node in self.subnodes:
119  node.writehan(writer, indent+addindent, addindent, newl)
120  if self.nodeType != Node.DOCUMENT:
121  writer.write("%s}%s" % (indent, newl))
122 

◆ writehan() [2/2]

def python.hanwriter.Node.writehan (   self,
  writer,
  indent = "",
  addindent = "",
  newl = "" 
)
inherited
Converts the object in a han string and writes it in the writer object

Definition at line 105 of file hanwriter.py.

105  def writehan(self, writer, indent="", addindent="", newl=""):
106  """
107  Converts the object in a han string and writes it in the writer object
108  """
109  writer.write(
110  indent+DQHanConfMaker._get_NodeType(self.nodeType)+" "+self.name)
111  # if it is a document do not need to add { }
112  if self.nodeType != Node.DOCUMENT:
113  writer.write(" { %s" % (newl))
114  if self.attributes:
115  for key, attribute in self.attributes.items():
116  writer.write("%s %s = %s%s" % (indent, key, attribute, newl))
117  if self.subnodes:
118  for node in self.subnodes:
119  node.writehan(writer, indent+addindent, addindent, newl)
120  if self.nodeType != Node.DOCUMENT:
121  writer.write("%s}%s" % (indent, newl))
122 

Member Data Documentation

◆ acceptChild

python.hanwriter.Document.acceptChild

Definition at line 523 of file hanwriter.py.

◆ attributes [1/2]

python.hanwriter.Node.attributes
inherited

Definition at line 66 of file hanwriter.py.

◆ attributes [2/2]

python.hanwriter.Node.attributes
inherited

Definition at line 66 of file hanwriter.py.

◆ father

python.hanwriter.HanOutput.father
inherited

Definition at line 460 of file hanwriter.py.

◆ name [1/2]

python.hanwriter.Node.name
inherited

Definition at line 70 of file hanwriter.py.

◆ name [2/2]

python.hanwriter.Node.name
inherited

Definition at line 70 of file hanwriter.py.

◆ nodeType

python.hanwriter.Document.nodeType

Definition at line 522 of file hanwriter.py.

◆ root_output_level

python.hanwriter.Document.root_output_level

Definition at line 525 of file hanwriter.py.

◆ subnodes [1/2]

python.hanwriter.Node.subnodes
inherited

Definition at line 65 of file hanwriter.py.

◆ subnodes [2/2]

python.hanwriter.Node.subnodes
inherited

Definition at line 65 of file hanwriter.py.


The documentation for this class was generated from the following file:
python.processes.powheg.ZZj_MiNNLO.ZZj_MiNNLO.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZj_MiNNLO.py:18
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
str
Definition: BTagTrackIpAccessor.cxx:11