Re: [ROOT] How toinstantiate a TH1D from a TProfile object

From: Rene Brun (Rene.Brun@cern.ch)
Date: Sun Dec 24 2000 - 14:43:59 MET


Hi Isi,
There is a function "ProjectionX" in TProfile to do this special
operation.
In your example, do:
  TH1D *sum = avgProf.ProjectionX();

We intend to revisit the unsatisfactory  situation with copy constructors
in Root soon.

Rene Brun

On Sat, 23 Dec 2000, Isard_Dunietz wrote:

> Happy holidays to you and all the rooters, and thank you for 
> your prompt answers, which are very helpful.
> 
> Question:
>    I would want to instantiate a TH1D object from a TProfile object.
> Since TProfile inherits from TH1D, I thought that the 
> conventional copy constructor of  TH1D should work just fine: such
> as in the code below, but there occured a segmentation violation.
> How do I instantiate a new TH1D object by copying the TH1D piece of a 
> TProfile object?:
> 
> This code below did not work:
> 
> root [7] sumProf
> (class TProfile)141811200
> root [8] TH1D sum( sumProf );
> 
>  *** Break *** segmentation violation
> Root > 
> 
> 
> ****************************
> so I tried something else, which also did not work:
> 
> root [2] TH1D sum;
> root [4] avgProf
> (class TProfile)141394304
> root [5] sum                                   
> (class TH1D)141817264
> root [6] sum = static_cast<TH1D> ( avgProf );  
> 
>  *** Break *** segmentation violation
> Root > 
> 
>     Thank you for your guidance here.   Happy new year.  Cheers, Isi
> 



This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:40 MET