Re: [ROOT] Add()ing hists with different number of bins.

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Sep 06 2002 - 17:28:01 MEST


Hi Brett,

A possible solution is to use TH1::Merge, TH2::Merge

Int_t TH2::Merge(TCollection *list)
{
   //Merge all histograms in the collection in this histogram.
   //This function computes the min/max for the axes,
   //compute a new number of bins, if necessary,
   //add bin contents, errors and statistics.
   //The function returns the merged number of entries if the merge is 
   //successfull, -1 otherwise.
   //
   //IMPORTANT remark. The 2 axis x and y may have different number
   //of bins and different limits, BUT the largest bin width must be
   //a multiple of the smallest bin width.


Rene Brun


On Tue, 27 Aug 2002 bv@bnl.gov wrote:

> Hi,
> 
> I want to Add() up a set of TH2Ds in to a single one, however, the
> individual ones were mistakenly booked with a different number of bins
> in the X direction.  (This is what you get with a detector that keeps
> growing durring data taking....).
> 
> The missing bins can just be considered to have zero content.  Is
> there some nice way to still add these hists together without looping
> over all the individual bins?
> 
> Thanks,
> -Brett.
> 



This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:51:08 MET