Re: Fitting with user defined function

From: Rene Brun (Rene.Brun@cern.ch)
Date: Mon Jan 05 1998 - 17:12:25 MET


Laurent Mirabito wrote:

> Hello ,
>
> I made a fit of a Landau distribution. To do this I translate the
> cernlib DENLAN function to C++ and load it with
>
> .L denlan.C
>
> and work as it is explained in the tutorials.
>
> It works but it's very slow compare to PAW ( > 5 min / few seconds)
>
> Is there any explanation to this ? I tried to make a library with
> a compile version of the function but I didn't find any way to load
> it...

If you run the macro below (fortran.C), you will get a Postscript file
explaining how to call Fortran from Root (from the interpreter).

Rene Brun


{
//=========Macro fortran.C describing how to link with Fortran routines
//  this macro generates a Postscript file "fortran.ps"

   TCanvas *c1 = new TCanvas("c1", "c1",100,10,700,900);
   c1->Range(0,0,20,24);
   c1->SetFillColor(10);
   c1->SetBorderSize(2);

   ptit = new TPaveText(1,22.5,19,23.8);
   ptit->AddText("Calling Fortran or C functions in a ROOT session");
   ptit->SetTextFont(62);
   ptit->SetTextSize(0.04);
   ptit->SetFillColor(42);
   ptit->Draw();

   t = new TText();
   t->SetTextFont(62);
   t->SetTextSize(0.035);
   t->SetTextColor(kRed);
   t->DrawText(1,21,"rootcint");
   t->SetTextColor(kBlue);
   t->DrawText(1,20,"f77");
   t->DrawText(1,19,"CC");
   t->DrawText(1,18,"CC");
   t->SetTextColor(kBlack);
   t->DrawText(3.57,21," -f myDict.cxx -c myFunctions.h myLinkDef.h");
   t->DrawText(2.3,20," -c +Z  +ppu denlan.f");
   t->DrawText(2.3,19," +O0 +a1 -z +Z -c -I$ROOTSYS/include
myDict.cxx");
   t->DrawText(2.3,18,"-O -b +a1 -z -o myFunctions.sl myDict.o
denlan.o");

   p1 = new TPaveText(0.4,10,10.9,17);
   p1->SetTextSize(0.03);
   p1->SetFillColor(19);
   p1->ReadFile("myFunctions.h");
   p1->SetAllWith("denlan","size",0.027);
   p1->SetAllWith("denlan","color",kBlue);
   p1->Draw();
   pl1 = new TPaveLabel(3,16.5,7.5,17.5,"myFunctions.h");
   pl1->Draw();

   p2 = new TPaveText(11.3,10,19.6,17);
   p2->SetTextSize(0.03);
   p2->SetFillColor(19);
   p2->ReadFile("myLinkDef.h");
   p2->SetAllWith("denlan","size",0.027);
   p2->SetAllWith("denlan","color",kBlue);
   p2->Draw();
   pl2 = new TPaveLabel(13.5,16.5,17,17.5,"myLinkDef.h");
   pl2->Draw();

   troot = new TText();
   troot->SetTextFont(72);
   troot->SetTextSize(0.04);
   troot->SetTextColor(2);
   troot->DrawText(2,6,"Root >");
   troot->DrawText(2,5,"Root >");
   t->SetTextSize(0.035);
   t->DrawText(4.7,6,"Float_t x = 1.5;");
   t->DrawText(4.7,5,"Double_t result = denlan_(x);");

   c1->Print("fortran.ps");
}



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