Re: [ROOT] Draw option ...

From: Rene Brun (Rene.Brun@cern.ch)
Date: Thu Mar 18 2004 - 08:39:43 MET


Hi Zaldy,

You were setting a marker size such that the marker was hidding the size 
of the error box when using the option "e2".
See below a simplified variant of your script using a THStack.

Rene

void hsample()
 {
    TCanvas* c1 = new TCanvas("c1","Modulation");
    Int_t NPoints=10000;

    TH1F * h_1 = new TH1F("h_1","Sample",10,-0.5,0.5);
    TH1F * h_2 = new TH1F("h_2","Sample",10,-0.5,0.5);

    for (int i = 0; i < NPoints; ++i) {
      double x = gRandom->Gaus(-0.5,0.5); //<------------Data for example
      double y = gRandom->Gaus(-0.5,0.5); //<------------MonteCarlo
      h_1->Fill(x);
      h_2->Fill(y);
    }

    h_2->SetFillColor(4);
    gStyle->SetErrorX(0.25);
    THStack *s = new THStack("s","MC and data;Layer;Count");
    s->Add(h_1);
    s->Add(h_2,"e2");
    s->Draw("nostack");
 }


zaldy wrote:
> 
> Dear Rene,
> 
> I post this mail at the roottalk mailing list.
> But it seems, what I want is not quite clear.
> 
> I want to superimpose MonteCarlo and Real Data such that I want the
> montecarlo to be drawn in box-type, with errors represented by the
> dimension of the box.
> 
> I have a simple script to reproduce what I want. See below.
> 
> My problem is I cannot control the error size(dimension of the box) in the
> montecarlo data. From the Manual it says...
> 
>  h_2->Draw("E2 same");
> 
> can do it. But I just can not  make it.
> 
> Hope to have your reply
> Thanks.
> 
> Zaldy
> ---am using Root Version   3.04/02  18 December 2002
> ---gcc 2.91.6
> 
> -------------------
> 
>  void hsample()
>  {
>     gROOT->Reset();
>     TCanvas* c1 = new TCanvas("c1","Modulation");
>     Int_t NPoints=10000;
> 
>     TH1F * h_1 = new TH1F("h_1","Sample",10,-0.5,0.5);
>     TH1F * h_2 = new TH1F("h_2","Sample",10,-0.5,0.5);
> 
>     for (int i = 0; i < NPoints; ++i) {
>       double x = gRandom->Gaus(-0.5,0.5); //<------------Data for example
>       double y = gRandom->Gaus(-0.5,0.5); //<------------MonteCarlo
>       h_1->Fill(x);
>       h_2->Fill(y);
>     }
> 
>     h_1->SetXTitle("Layer");
>     h_1->SetYTitle("Count");
> 
>     h_1->SetMarkerStyle(21);
>     h_1->Draw();
>     h_2->SetLineColor(4);
>     h_2->SetMarkerStyle(25);
>     h_2->SetMarkerSize(5.);
>     h_2->Draw("E0 same");
>  }
> 
> 
> 
> On Mon, 15 Mar 2004, zaldy wrote:
> 
> >
> > Dear Rooters,
> >
> >
> > I just wanted to draw a point from the TH1F object.
> > I want it to be a box such that the error bars represents the width and
> > length of the box. This is very helpful if we want to compare a MonteCarlo
> > Data and a true data.
> >
> > I tried something like this:
> >
> >  TH1F * h = new TH1F(....);
> >  .....
> >  fill the histogram
> >  ......
> >  h->SetMarkerStyle(25);
> >  h->Draw("e2");
> >
> > There is actually a box on a coordinate but it does not represent the
> > errors of the histogram. SO if I want to have a logscale(X or Y), the box
> > does not response to the logscale.
> >
> > Can you suggest how to do it?
> >
> >
> > Thanks.
> >
> >
> >
> 
> --
> 
> --------------------------------------------------------
>                    Zaldy A. Nawang
>                    PS Users Room 2
>                    Yon Gokan,
>                    E362, Neutrino Group,
>                    IPNS, KEK,
>                    Japan
> 
>                    e-mail: zaldy@neutrino.kek.jp
>                    Tel. No. : (81) 029864 - 5387
> --------------------------------------------------------



This archive was generated by hypermail 2b29 : Sun Jan 02 2005 - 05:50:06 MET