RE: [ROOT] TTree::Draw LineStyle Otptions

From: Philippe Canal (pcanal@fnal.gov)
Date: Fri Aug 15 2003 - 17:06:19 MEST


Hi Andreas,

Note that after doing:
   TH1F* hist1 = new TH1F();
   tree->Draw("variable1>>hist1(10, 0, 10)", "", "");
There is NO relation being the object pointed to by the variable 'hist1' and
the histogam drawn on the screen.  The relation is done using the 'ROOT
name' of the object and NOT the name of variable that point to it.

Do either
   TH1F* hist1pointer = new TH1F("hist1name","hist1title",10,0,10);
   tree->Draw("variable1>>hist1", "", "");
or
   tree->Draw("variable1>>hist1(10, 0, 10)", "", "");
   TH1F* hist1pointer = (TH1F*)gDirectory->Get("hist");

> gStyle->SetHistLineStyle(3); .. does not work

By default, when an histogram is created by the TTree::Draw command, the
graphical attributes are determined by the TTree.  If the tree is retrieve
from a file, thoses attributes are read from the
file rather than gStyle.

To force histogram and TTree which are read from a file to update their
attribute using the current gStyle use:
	gROOT->ForceStyle();
So you can do either:
	tree->SetLineStyle(3);
       tree->Draw("variable1>>hist1(10, 0, 10)", "", "");
or
	gStyle->SetHistLineStyle(3);
	gROOT->ForceStyle();
       tree->Draw("variable1>>hist1(10, 0, 10)", "", "");
or
	gStyle->SetHistLineStyle(3);
       TH1F* hist1pointer = new TH1F("hist1name","hist1title",10,0,10);
       tree->Draw("variable1>>hist1", "", "");

Cheers,
Philippe.



-----Original Message-----
From: owner-roottalk@pcroot.cern.ch
[mailto:owner-roottalk@pcroot.cern.ch]On Behalf Of Andreas Salzburger
Sent: Friday, August 15, 2003 4:21 AM
To: Roottalk
Subject: [ROOT] TTree::Draw LineStyle Otptions


Hi roottalkers,

i think i have a simple question, but somehow i can't manage to do it:

i try to compare to plots which i create from a tree, so first i create to
histograms

TH1F* hist1 = new TH1F();
TH1F* hist2 = new TH1F();

then i do the following:

tree->Draw("variable1>>hist1(10, 0, 10)", "", "");
tree->Draw("variable2>>hist2(10, 0, 10)", "", "same");

works out fine, but then i wanted to draw one with a dashed line!

neither does
	hist1->SetLineStyle(3);
work, nor
	gStyle->SetHistLineStyle(3);



anyway i'm reading a rootlogon.C script predefining my styles, but even if
i insert
	gStyle->SetHistLineStyle(3);
in the script, the LineStyle is solid.

has anyone an idea how to solve that?

thanks in advance,
andreas

p.s.
echo $ROOTSYS
/afs/cern.ch/sw/root/v3.05.04/rh73_gcc32/root



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