Re: [ROOT] Using ProjectionY histogram in a fit.

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Mar 22 2004 - 21:46:12 MET


Hi Bill,

Replace
    Raw->ProjectionY("phidist",5,34,"ed");
by
    TH1D *phidist = Raw->ProjectionY("phidist",5,34,"ed");


Rene Brun

On Mon, 22 Mar 
2004, William 
Love wrote:

> Rooters
>   I*******************************************
>   *                                         *
>   *        W E L C O M E  to  R O O T       *
>   *                                         *
>   *   Version   3.10/01    8 October 2003   *
> 
>   On RedHat Linux
> 
>   
>  I am trying to fit the ProjectionY of a 2D histogram.
>  A little extract test looks like this:
>  
> 
> #include "TVirtualFitter.h"
> #include "TMath.h"
> #include "TFile.h"
> #include "TStopwatch.h"
> 
> #include "TH2.h"
> #include "TF2.h"
> #include "TH1.h"
> #include "TF1.h"
> 
> #include <stdlib.h>
> #include <stdio.h>
> #include <iostream.h>
> 
> 
> TFile *fin;
> TH2D *Raw;
> TH1D *phidist= 0;
> 
> //__________________________________________________
> void tester()
> {
> 
>     // input the data
>    fin = TFile::Open("~love/root/samron/aya/mergeAll.root","READ");
>   fin->cd();
>   Raw = (TH2D *)fin->Get("SameUnl");
>   Raw->Sumw2();
>   Raw->Scale(4.5e-9);
>   Raw->ProjectionY("phidist",5,34,"ed");
> 
>   cout << " input file opened - histogram SameUnl" << endl; 
>     Double_t datum = phidist->GetBinContent(1);
>   cout << datum << endl;
>   }
>  
>   I compile this by .x tester.cxx++
> 
> The next to last line (GetBinContent) or any other reference to the 
>  phidist histogram produces a segmentation fault.  At that point 
>  CINT is capable of doing all necessary things with phidist but
>  the compiled code isn't.  Where am I going wrong?
> 
>                                    Bill Love



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET