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 510 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 517 of file hanwriter.py.

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

Member Function Documentation

◆ __str__() [1/2]

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

Definition at line 191 of file hanwriter.py.

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

◆ __str__() [2/2]

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

Definition at line 191 of file hanwriter.py.

191  def __str__(self):
192  return "HanNode: "+self.name+" ("+DQHanConfMaker._get_NodeType(self.nodeType)+") Attributes:"+str(self.attributes)+" SubNodes: "+str(self.subnodes)
193 
194 
195 # HanHistogram class
196 # 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 417 of file hanwriter.py.

417  def addHistogram(self, histogram, algorithm, annotations={}, output=DQHanConfMaker._default_output, attributes={}):
418  """
419  Adds to the directory a histogram specifying the histogram name, the algorithm and the output path.
420  """
421  histo = HanHistogram(histogram, algorithm,
422  annotations, output, attributes)
423  self.appendChild(histo)
424  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 535 of file hanwriter.py.

535  def addOutput(self, name, algorithm, annotations={}, attributes={}):
536  """
537  Adds a sub output element with name and algorithm
538  """
539  # forward to root region
540  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 402 of file hanwriter.py.

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

◆ appendChild() [1/2]

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

Definition at line 127 of file hanwriter.py.

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

◆ appendChild() [2/2]

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

Definition at line 127 of file hanwriter.py.

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

◆ getAlgorithm() [1/2]

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

Definition at line 469 of file hanwriter.py.

469  def getAlgorithm(self):
470  """
471  Gets the algorithm attribute
472  """
473  if 'algorithm' in self.attributes:
474  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 545 of file hanwriter.py.

545  def getAlgorithm(self, name):
546  """
547  retrieves the algorithm han object associated with name
548  """
549  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 169 of file hanwriter.py.

169  def getAttribute(self, key):
170  """
171  Gets the attribute identified by the key, None if not found
172  """
173  if self.attributes and key in self.attributes:
174  return self.attributes[key]
175  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 169 of file hanwriter.py.

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

◆ getOutputPath()

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

Definition at line 494 of file hanwriter.py.

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

◆ getReference()

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

Definition at line 554 of file hanwriter.py.

554  def getReference(self, name):
555  """
556  retrieves the han reference associated with name
557  """
558  return self.getSubNode(name, Node.REFERENCE)
559 
560 
561 # Add a DQParameter object to the HanDocument
562 # @param handocument: the document containing the configuration @c handocument: a HanDocument object
563 # @param dqparameter: the DQParameter object @c dqparameter: a DQParameter object
564 # @param output: the output element for the result
565 # @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 428 of file hanwriter.py.

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

◆ getSubNode() [1/2]

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

Definition at line 181 of file hanwriter.py.

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

◆ getSubNode() [2/2]

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

Definition at line 181 of file hanwriter.py.

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

◆ removeAttribute() [1/2]

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

Definition at line 157 of file hanwriter.py.

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

◆ removeAttribute() [2/2]

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

Definition at line 157 of file hanwriter.py.

157  def removeAttribute(self, key):
158  """
159  Removes attribute identified by key
160  """
161  if self.attributes and key in self.attributes:
162  del self.attributes[key]
163  return True
164  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 146 of file hanwriter.py.

146  def setAttribute(self, key, attribute):
147  """
148  The attribute identified by key is added to this node
149  """
150  if not self.attributes:
151  self.attributes = {}
152  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 146 of file hanwriter.py.

146  def setAttribute(self, key, attribute):
147  """
148  The attribute identified by key is added to this node
149  """
150  if not self.attributes:
151  self.attributes = {}
152  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  import six
94  writer = io.BytesIO() if six.PY2 else io.StringIO()
95  if encoding is not None:
96  import codecs
97  writer = codecs.lookup(encoding)[3](writer)
98  self.writehan(writer, "", indent, newl)
99  return writer.getvalue()
100 

◆ 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  import six
94  writer = io.BytesIO() if six.PY2 else io.StringIO()
95  if encoding is not None:
96  import codecs
97  writer = codecs.lookup(encoding)[3](writer)
98  self.writehan(writer, "", indent, newl)
99  return writer.getvalue()
100 

◆ 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 106 of file hanwriter.py.

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

◆ 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 106 of file hanwriter.py.

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

Member Data Documentation

◆ acceptChild

python.hanwriter.Document.acceptChild

Definition at line 524 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 461 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 523 of file hanwriter.py.

◆ root_output_level

python.hanwriter.Document.root_output_level

Definition at line 526 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:
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:71
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
str
Definition: BTagTrackIpAccessor.cxx:11