Re: Direct copy of a histogram

From: Rene Brun (Rene.Brun@cern.ch)
Date: Fri Feb 05 1999 - 09:40:11 MET


Christoph Borgmeier wrote:
> 
> Hello,
> 
> I just ran into the same problem as Wei Xie did last year: An existing
> histogram has to be overwritten. I do not want to delete it and copy
> constuct a new one, since it is attached to lists. I have only a TH1
> pointer, while the histogram is of type TH1F or TH2F (or maybe something
> else).
> 

Hi Christoph,
What do you want to do exactly?
You can do all sorts of operations with an histogram:
  TH1::Reset()
  TH1::Add  to replace its contents by another histogram contents

Also note that you can detach an histogram from a directory by calling
  TH1::SetDirectory(0)

Rene Brun


> Fons Rademakers wrote on 25 Jun 1998:
> > use either the histogram TH1::operator=() or the TH1::Copy()
> > or the TObject::Clone() methods.
> >
> > Cheers, Fons.
> >
> > Wei Xie wrote:
> > >
> > > Dear ROOTers'
> > >
> > > Is there a way to copy one histogram directly to another
> > > histogram ?
> [...]
> 
> As far as I understand it,
> 
> * TH1::operator does not copy the entire object (no polymorphism
>   possible),
> 
> * TH1::Copy() is protected,
> 
> * TObject::Clone() creates a new object in a different memory location.
> 
> Do I miss the point here? Do I have to use memcpy (*shudder*)?
> 
> Thank you for your answer
> Christoph
> 
> --
>  Christoph Borgmeier    Mail:  DESY F15/HERA-B, Geb. 61/117
>                                Notkestr. 85, 22607 Hamburg
>  Humboldt Univ Berlin   Phone: +49 40 8998 4850
>                         Email: Christoph.Borgmeier@desy.de



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:28 MET