Hi Birger,
Here is a small example showing how to solve your problem.
{
gROOT->Reset();
TFile f1("file1.root");
TTree *t1=(TTree*)f1.Get("T");
TFile f2("file2.root");
TTree *t2=(TTree*)f2.Get("T");
gROOT->cd();
TH1F h1("h1","test1",100,0,1);
TH1F h2("h2","test2",100,0,1);
t2->Draw("var>>h2");
t1->Draw("var>>h1","","same");
}
Rene Brun
Birger Koblitz wrote:
>
> Hi,
>
> I have some root-files converted from hbook files containing ntuples. They
> all have the same name, h133. Now I would like to plot some variables out
> of these files on top of each other, the files contain different MC's.
> What I am doing now is:
> // A list of files
> char *fname[]={"qcdins.root","qcdins_196.root","qcdins_234.root"};
> char *hname[]={"h01","h02","h03"};
> char strbuf[32];
> // Read in the files:
> ....
> for(i=0;i<3;i++){
> // CD into the dirs
> strcpy(strbuf,fname[i]);
> strcat(strbuf,":HZINS");
> ((TFile*)gROOT->GetListOfFiles()->FindObject(fname[i]))->cd(strbuf);
> histo=new TH1F(hname[i]," ",20,minx,maxx);
> strcpy(strbuf,"x"); // x is the variable name to be plotted
> strcat(strbuf,">>");
> strcat(strbuf,hname[i]);
> h133->Draw(strbuf,"wght*(ptje>1.)");
>
> if(i==0){
> histo[i]->DrawClone();
> }else{
> histo[i]->DrawClone("same");
> }
> c1->Update();
> }
>
> This does not work, probably because the histos are created in the
> subdirs, they are drawn once but vanish when the next histo is plotted.
> How does one get them into a common dir, can't one make then somewhat
> global?
> Why does it not help to use DrawClone or DrawCopy?
> Can someone give me a hint how one should do this?
>
> Thanks in advance,
> Birger
>
> /------------------------------------------------------------\
> | Birger Koblitz koblitz@mail.desy.de |
> | Max-Planck-Institut fuer Physik |
> | (Werner Heisenberg-Institut) |
> | DESY-FH1K Tel. (40) 8998-3971 |
> | Notkestr. 85 |
> | D-22603 HAMBURG |
> \------------------------------------------------------------/
This archive was generated by hypermail 2b29 : Tue Jan 02 2001 - 11:50:24 MET