Message: RE: Help on AIDA histograms Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None RE: Help on AIDA histograms 

Forum: Analysis
Re: Question Help on AIDA histograms (Gabriel Sawakuchi)
Date: 15 Nov, 2005
From: <tony_johnson@slac.stanford.edu>

> Hello,
> 
> I have 14 AIDA::IHistogram1D with the same bin size and length. 
> I would like to add them to form 1 IHistogram1D but I would 
> like to keep the information of all histograms by means of colors. 
> Pretty much I would like to have something like this example:
> 
> http://jas.freehep.org/index_old.htm
> 
> How can I do that ?

You can overlay multiple histograms when you display them, simply by plotting them all in the same plotter region. If you want to stack them all on top of each other you need to do a little more work to add them together appropriately, since the plotter does not natively support stacking (perhaps it should).

Here is a sample script, hopefully you can translate it to C++:

IAnalysisFactory = class hep.aida.IAnalysisFactory
af = IAnalysisFactory::create()
tree = af.createTreeFactory().create()
hf = af.createHistogramFactory(tree)

Random = class java.util.Random
r = Random()

// Make 14 random histograms

ArrayList = class java.util.ArrayList
histograms = ArrayList() 
for (i=0; i<14; i++)
{
   histogram = hf.createHistogram1D("Histogram "+i,50,0,1)
   for (j=0; j<10000; j++)
   {
      histogram.fill(r.nextDouble())
   }
   histograms.add(histogram)
}

// Overlay them
plotter = af.createPlotterFactory().create("Overlay Example")
for (h : histograms)
{
   plotter.region(0).plot(h)
}
plotter.show()

// Stack them on top of each other
stack = ArrayList()
for (i=0; i<histograms.size(); i++)
{
   s = hf.createHistogram1D("Stack "+i,50,0,1)
   s.add(histograms.get(i))
   if (i>0) s.add(stack.get(i-1))
   stack.add(s)
}
plotter = af.createPlotterFactory().create("Stack Example")
for (i=stack.size(); i>0; i--)
{
   plotter.region(0).plot(stack.get(i-1))
}
plotter.show()


Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Question: RE: Help on AIDA histograms   (Gabriel Sawakuchi - 17 Nov, 2005)
(_ More: RE: Help on AIDA histograms   (Gabriel Sawakuchi - 18 Nov, 2005)
(_ Feedback: RE: Help on AIDA histograms   (Gabriel Sawakuchi - 23 Nov, 2005)
 Add Message Add Message
to: "RE: Help on AIDA histograms"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]