[ROOT] My procedure using TExec is wrong ?

From: Harufumi Tsuchiya (harufumi@icrr.u-tokyo.ac.jp)
Date: Tue Dec 04 2001 - 04:21:51 MET


Dear ROOTers,

Now, I try to execute my original function via TExex.
But, I do not succeed in doing this.

My procedure is like this

I modified cexec.C in 
http://root.cern.ch/cgi-bin/print_hit_bold.pl/root/roottalk/roottalk01/2830.html?cexec#first_hit for my aim. 
In my program, cproject() in cexec.C was renamed to ProjectionXY().

ProjectionXY() is like this.

void ProjectionXY() {
  TAxis *xaxis = h->GetXaxis();
  TAxis *yaxis = h->GetYaxis();
  Int_t ixmin = xaxis->GetFirst();
  Int_t ixmax = xaxis->GetLast();
  Int_t iymin = yaxis->GetFirst();
  Int_t iymax = yaxis->GetLast();
  if (h1_px) delete h1_px; if (h1_py) delete h1_py;
  // Projection to X axis
  pad[1]->cd();
  h1_px = (TH1F*)h->ProjectionX("h1_px",iymin, iymax);
  h1_px->GetXaxis()->SetRange(ixmin, ixmax);
  h1_px->Draw();   
  gPad->Modified();
  // Projection to Y axis
  pad[2]->cd();
  h1_py = (TH1F*)h->ProjectionY("h1_py",ixmin, ixmax);
  h1_py->GetYaxis()->SetRange(iymin, iymax);
  h1_py->Draw();   
  gPad->Modified();
}  

I divied canvas into 4 sections and colar map produced via 
h->Draw("colz") is displayed at pad[0].
I would like to display each projection of h along x and y axis
at pad[1] and pad[2], respectively.
h is already filled via TH2F::Fill() before calling ProjectionXY.
ProjectionXY is defined like above in my main program and used like this.

      :
      :
TExec *ex_proj = new TExec("ex_proj", "ProjectionXY()");
h->GetListOfFunctions()->Add(ex_proj);
h1_px = 0; h1_py = 0;
pad[0]->cd();
h->Draw("colz");
      :
      :

I compiled my program via g++ successfully and run.
But, I got error message below.

Error: Function ProjectionXY() is not defined in current scope  FILE:/var/tmp/tmp.1.Wa1kvA_cint LINE:1
Possible candidates are...
filename       line:size busy function type and name  
*** Interpreter error recovered ***

Only color map was drawn at pad[0] and no histogram appeared at other pads.
I zoomed the this map on canvas and also got the same error mesasge above.
(Zooming itsef could be done successfully.)

What is wrong ?

Please tell me correct way.

I use ROOT version 3.02.04 on FreeBSD 4.3 and version of g++ is 2.95.3.

Harufumi Tsuchiya 



This archive was generated by hypermail 2b29 : Tue Jan 01 2002 - 17:51:10 MET