Hi Tommaso,
In your function ZtrueConvolve (called multiple times), you create a
function TF1 with always the same name "zfunc7". This erases the previous
function
with the same name.
There are two solutions to this problem:
- create the function with a different name at each call
- or simply replace
fgaus->Draw(option);
by
fgaus->DrawCopy(option);
Rene Brun
Tommaso Chiarusi-MACRO wrote:
>
> Dear Rooters,
> my problem is this:
>
> I have a class Deco that has the method
> ZTrueConvolve()
>
> it performs the convolution of some data, by "gaussianiously" smearing
> each entries.
>
> Id est:
> For each entry (in my case the Z of a nucleous) a normalization factor is
> computed and then, since the sigma_Z is the same for all the entry,
> always inside ZTrueConvolve(), a function is called that takes into
> consideration as many as the entries and sums up all the relative
> gaussians, returning the final function (clearly a multi gaussian
> summation) fgaus.
> Always inside ZTrueConvolve there is then the command
> fgaus->Draw(option)
>
> where option could be specified by the user.
>
> The class is attached, but a very rough sketch is the following:
>
> Class Deco(...)
>
> ...
>
> double zfunc7(Double_t *x, Double_t *par)
> {
> double fitval=0;
> int i=2;
> int limite = par[0]+2;
> while(i<limite)
> {
> fitval += par[i]*TMath::Exp(-TMath::pow(x[0]-i-par[1]+2,2)
> /(2*TMath::pow(Deco::ZRes(),2)));
> i++;
> }
> return fitval;
> }
>
> //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> //this is the function
>
> void Deco::ZTrueConvolve(char* option, int nvb)
> // option is the Draw option (i.g. "same")
> // nvb is the index for 3 types of final functions
> {
>
> ... // some declarations etc...
>
> TF1 *fgaus= new TF1("zfunc7",zfunc7,_zmin,_zmax,limite);
>
> // set the parameters for the function
>
> fgaus->SetParameter(0,nozbin);
> fgaus->SetParameter(1,_zmin);
>
> int iset=0;
>
> while(iset<nozbin){
> norm=A(iset) // get the normalization factor
> fgaus->SetParameter(iset+2,norm);
> iset++;
> }
>
>
> fgaus->Print();
> fgaus->SetTitle();
> fgaus->Draw(option);
>
> //end ZTrueConvolve
> }
>
> //^^^^^^^^^^^^^^^^^^^^^^^^^^^
> // this is the method
>
> Well, the problem is that I cannot superimpose different plot, since if I
> do (et assume that "da" is the object of class Deco)
>
> da.ZTrueConvolve("",1);
> da.ZTrueConvolve("same",2);
>
> the first plot disappears and the second is plot without the frame.
>
> Where I miss the ownership?
>
> I try to add the line
>
> fgaus->SetDirectory(0);
>
> after I "->Draw()"ed it... but it seems not to work wit my Root Version
> (3.00)
>
> Thanks Tommaso
>
> --------------------------------------------------------------------------------
>
> Name: Deco.h
> Deco.h Type: Plain Text (TEXT/PLAIN)
> Encoding: BASE64
>
> Name: Deco.C
> Deco.C Type: Plain Text (TEXT/PLAIN)
> Encoding: BASE64
This archive was generated by hypermail 2b29 : Sat Jan 04 2003 - 23:50:40 MET