The Gaudi Framework  master (594c33fa)
GaudiAlg.HistoUtils.HistoFile Class Reference

Public Member Functions

def __init__ (self, fileName)
 
def save (self, *args)
 
def close (self)
 

Public Attributes

 file
 
 aida2root
 
 aidaTypes
 

Private Member Functions

def __convertibleType (self, histo)
 

Static Private Attributes

 __author__
 

Detailed Description

Class to write histograms to a ROOT file.
hFile = HistoFile("myFile.root")
myHisto = ...
hFile.save(myHisto)
myHisto0 = ...
myHisto1 = ...
myHisto2 = ...
hFile.save(myHisto0, myHisto1, myHisto2)
histoList = [h0, h1, h2, h3]
hFile.save(histoList)
...
hWriter.close()

Definition at line 1008 of file HistoUtils.py.

Constructor & Destructor Documentation

◆ __init__()

def GaudiAlg.HistoUtils.HistoFile.__init__ (   self,
  fileName 
)

Definition at line 1026 of file HistoUtils.py.

1026  def __init__(self, fileName):
1027  self.file = ROOT.TFile(fileName, "RECREATE")
1028  from GaudiPython import gbl
1029 
1030  self.aida2root = gbl.Gaudi.Utils.Aida2ROOT.aida2root
1031  self.aidaTypes = [
1032  gbl.AIDA.IHistogram1D,
1033  gbl.AIDA.IHistogram2D,
1034  gbl.AIDA.IHistogram3D,
1035  gbl.AIDA.IProfile1D,
1036  gbl.AIDA.IProfile2D,
1037  gbl.AIDA.IHistogram,
1038  ]
1039 

Member Function Documentation

◆ __convertibleType()

def GaudiAlg.HistoUtils.HistoFile.__convertibleType (   self,
  histo 
)
private

Definition at line 1040 of file HistoUtils.py.

1040  def __convertibleType(self, histo):
1041  histoType = type(histo)
1042  for t in self.aidaTypes:
1043  if histoType == t:
1044  return True
1045  return False
1046 

◆ close()

def GaudiAlg.HistoUtils.HistoFile.close (   self)

Definition at line 1063 of file HistoUtils.py.

1063  def close(self):
1064  self.file.Write()
1065  self.file.Close()
1066 
1067 
1068 # =============================================================================

◆ save()

def GaudiAlg.HistoUtils.HistoFile.save (   self,
args 
)
This function stores histograms on the file for future saving.
It takes an arbitrary number of AIDA or ROOT histograms or
a list of them.

Definition at line 1047 of file HistoUtils.py.

1047  def save(self, *args):
1048  """
1049  This function stores histograms on the file for future saving.
1050  It takes an arbitrary number of AIDA or ROOT histograms or
1051  a list of them.
1052  """
1053  if args:
1054  if isinstance(args[0], list):
1055  histoList = args[0]
1056  else:
1057  histoList = args
1058  for h in histoList:
1059  if self.__convertibleType(h):
1060  h = self.aida2root(h)
1061  h.Write()
1062 

Member Data Documentation

◆ __author__

GaudiAlg.HistoUtils.HistoFile.__author__
staticprivate

Definition at line 1024 of file HistoUtils.py.

◆ aida2root

GaudiAlg.HistoUtils.HistoFile.aida2root

Definition at line 1030 of file HistoUtils.py.

◆ aidaTypes

GaudiAlg.HistoUtils.HistoFile.aidaTypes

Definition at line 1031 of file HistoUtils.py.

◆ file

GaudiAlg.HistoUtils.HistoFile.file

Definition at line 1027 of file HistoUtils.py.


The documentation for this class was generated from the following file:
gaudirun.type
type
Definition: gaudirun.py:160
Write
Definition: Write.py:1