[ROOT] Clone TF1 objects

From: Stanislav NESTEROV (Stanislav.Nesterov@cern.ch)
Date: Fri Nov 29 2002 - 16:38:12 MET


   Dear Rene,
   
   I've encounter small problem while trying to clone TF1 objects. 
After user function defenition I'm passing parameters to this new function 
and everything is works fine. But when I'm cloning this function and 
passing  new parameter to it, newly created function don't get this 
parameter as if it has ZERO parameters.
  The problem here is that Cloned object rejects to change parameters 
of the function.
   Below I put small example that reproduce this problem. The second 
function `dedxpf' always has `par[0]==0', i.e. after cloning this TF1 
object doesn't chage its parameters. So it is drawn as zero line.


ROOT-3.03/09 RH7.2gcc296.
			Best regards,
					Stanislav.




 Double_t func(Double_t*x,Double_t*par) {
  Float_t massa=par[0];
  if(x[0]==0.) return 0.;
  if(massa==0.) return 0.;
  Float_t pmp=(massa*massa/(x[0]*x[0]));
  Float_t beta = 1./TMath::Sqrt(1+pmp);
  return beta;
}
void pp(){
  TF1 *dedxf = new TF1("dedx",func,0.05,1.,1);
  TCanvas *cc=new TCanvas("cc","Canvas",600,600);
  
  TH2F *hh=new TH2F("hh","HH",50,0.05,1.,50,0,3);
  TF1* dedxpf = (TF1*)dedxf->Clone();
  dedxf->SetParameter(0,0.13957);
  dedxpf->SetParameter(0,0.93827);
  hh->GetListOfFunctions()->Add(dedxf);
  hh->GetListOfFunctions()->Add(dedxpf);
  hh->FillRandom("gaus");
  hh->Draw();
  
}



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