[ROOT] Problem with TTree::Draw to a histogram in C++

From: Guy Ron (ronguy@tauphy.tau.ac.il)
Date: Thu Jun 19 2003 - 09:23:19 MEST


Hi All,
I need to plot some histograms from a ROOT File, to do so I use a function
as follows:
void DispBar(int plane,int bar)
{

  c1=new TCanvas();
  TFile BF("/home/rshneor/bbtreefile.root");
  TTree *BT=(TTree *)BF.Get("bbtree");
  if (plane==0) {

    printf("AUX Plane Bar: %i\n",bar);
  } else if (plane==1) {

    printf("DE Plane Bar: %i\n",bar);

  } else if (plane==2) {

      sprintf(dummy,"E Plane Channel %i TDC Left",bar);
      TH1F tdcl("tdcl",dummy,100,0,2000);
      sprintf(dummy,"E Plane Channel %i TDC Right",bar);
      TH1F tdcr("tdcr",dummy,100,0,2000);
      sprintf(dummy,"E Plane Channel %i ADC Left",bar);
      TH1F adcl("adcl",dummy,100,0,2000);
      sprintf(dummy,"E Plane Channel %i ADC Right",bar);
      TH1F adcr("adcr",dummy,100,0,100);


      c1->Divide(2,2);
      sprintf(dummy,"BB.tp.e.lt.data[%i]>>tdcl",bar-1);
      sprintf(dummy1,"BB.tp.e.lt.data[%i]>0",bar-1);
      c1->cd(1);
      BT->Draw(dummy,dummy1);

      c1->cd(2);
      sprintf(dummy,"BB.tp.e.rt.data[%i]>>tdcr",bar-1);
      BT->Draw(dummy);
      c1->cd(3);
      sprintf(dummy,"BB.tp.e.la.data[%i]>>adcl",bar-1);
      BT->Draw(dummy);
      c1->cd(4);
      sprintf(dummy,"BB.tp.e.ra.data[%i]>>adcr",bar-1);
      printf(dummy);
      BT->Draw(dummy);

  }
}

The problem is that I get blank pads in the canvas... When I try to plot
from the tree without the redirection to the histograms everything works
fine, however, when I try the same code (with the redirection) in the
interpreter it also works fine.

Any help you can offer would be greatly appreciated.

Thanks,
	Guy Ron
	Tel Aviv University



This archive was generated by hypermail 2b29 : Thu Jan 01 2004 - 17:50:12 MET