Access to TGraph from Tree->Draw 2D

From: Jean-Eric Campagne <campagne_at_lal.in2p3.fr>
Date: Mon, 23 May 2005 15:34:18 +0200


Hello,
I would like to access the TGraph created by a TTree->Draw(x1:x2) as in the folowing:

  T1.Draw("numum:log10enm","log10enm>-1 && log10enm<2");   TGraph *graph = (TGraph*)gPad->GetPrimitive("graph");

But graph seems to be 0. My complete C macro is:

{

   TGaxis::SetMaxDigits(2);
  //gStyle->SetOptStat(1); //stat
   TCanvas* c1 = new TCanvas("c1","SPL Flux",100,100,600,600);

  c1->SetGridx();
  c1->SetGridy();
  c1->SetLogx();

  //draw a dummy frame
  TH2D* hdum = new TH2D("hdum","Lipari Xcc",10,1e-1,1e2,10,0,1.6);

  hdum->SetXTitle("E_{#nu} (GeV)");
  hdum->SetYTitle("#sigma/E (10^{-38}cm^{2})/GeV");
  hdum->Draw();

  TPad *overlay = new TPad("overlay","",
			   gStyle->GetPadLeftMargin(),
			   gStyle->GetPadBottomMargin(),
			   1-gStyle->GetPadRightMargin(),
			   1-gStyle->GetPadTopMargin());
  overlay->SetFillStyle(4000);

  overlay->Draw();
  overlay->Range(-1.,0.,2.,1.6); //set the range in linear scale

  TTree T1("t1","Xsection CC");
  //Globes x-section  

T1.ReadFile("./LipSezUrtoMauro.txt","log10enm/F:nuem/F:numum/F:nutaum/F:anuem/F:anumum/F:anutaum/F");   overlay->cd();
  T1.Draw("numum:log10enm","log10enm>-1 && log10enm<2");   TGraph *graph = (TGraph*)gPad->GetPrimitive("graph");   graph->SetLineColor(4);
  graph->Draw("LSAME");
}

Of course when I only Draw with LSAME option it is Ok, but I do not manage to change the color of the line...

An idea?
J.E

...........................................................................
.LAL - IN2P3 - CNRS
.LAL - B.P 34 - 91898 Orsay Cedex - France
.Piece 108
.Tel +33 (0)1 64 46 84 29
.Fax +33 (0)1 64 46 83 97
...........................................................................
Received on Mon May 23 2005 - 15:34:29 MEST

This archive was generated by hypermail 2.2.0 : Tue Jan 02 2007 - 14:45:08 MET