14 *******************************************************************************
16 * Simple example which illustrate the usage of useful algorithm base class *
17 * HistoAlgo (python version of C++ GaudiHistoAlg) for 'easy' histogramming. *
19 * This example illustrates the usage of 1D and 2D profile histograms *
21 *******************************************************************************
23 from __future__
import print_function
26 __author__ =
"Vanya BELYAEV ibelyaev@physics.syr.edu"
41 """Simple algorithm which explicitly book&fill profile histograms"""
45 HistoAlgo.__init__(self, name)
48 """The major method 'execute', it is invoked for each event"""
51 for i
in range(0, 1000):
54 self.plot2D(x, y,
" x vs y ", -2, 2, -4, 4)
55 self.plot2D(x, y + 3 * x,
" x vs y+3x ", -2, 2, -4, 4)
56 self.plot2D(x, y - 3 * x,
" x vs y-3x ", -2, 2, -4, 4)
57 self.profile1D(x, y,
" x vs y (profile)", -2, 2)
58 self.profile1D(x, y + 3 * x,
" x vs y+3x (profile)", -2, 2)
59 self.profile1D(x, y - 3 * x,
" x vs y-3x (profile)", -2, 2)
67 """Configuration of the job"""
78 hsvc = gaudi.service(
"HistogramPersistencySvc")
79 hsvc.OutputFile =
"histoex2.root"
82 gaudi.addAlgorithm(alg)
92 if "__main__" == __name__:
93 print(__doc__ + __author__)
104 for alg
in (
"HistoEx",
"HistoEx1",
"HistoEx2"):
105 alg = gaudi.algorithm(alg)
106 histos = alg.Histos()
107 for key
in sorted(histos):
109 print(
" Alg='%s', ID='%s' , Histo=%s " % (alg.name(), key, histo))
110 if hasattr(histo,
"dump"):
111 print(histo.dump(60, 20,
True))