Re: 3 dim scaterplot and event display

Rene Brun (brun@hpbrun.cern.ch)
Mon, 9 Mar 1998 21:38:58 +0100 (MET)


If I understand correctly your mail, you simply want
to display your variable DE as a function of x and y.
You do not need to create an ntuple to do that.
I have modified your macro, see below:

Rene Brun

//---------------macro cube.C-------------------------------
{
gROOT->Reset();
page=new TCanvas("page","CUBE",0,0,500,700);

TH2F *h1 = new TH2F("h1","CUBE",16,-100,100,16,-100,100);

Int_t ans;
Float_t x,y,dE;
// 2 events
Float_t xx[2][3]={-97.5,-71.5,-58.5,-97.5,71.5,-18.5};
Float_t yy[2][3]={-84.5,-84.5,-71.5,-84.5,4.5,71.5};
Float_t dEE[2][3]={13.5,18.25,17.5,3.5,10.51,11.5};

for (Int_t j=0; j<2;j++) {
for (Int_t i=0; i<3;i++)
{
x=xx[j][i];
y=yy[j][i];
dE=dEE[j][i];
h1->Fill(x,y,dE);
}

page->cd();
page->GetFrame()->SetFillColor(42);
page->GetFrame()->SetBorderMode(-1);
page->GetFrame()->SetBorderSize(5);
h1.SetLineWidth(2);
h1.SetXTitle("x");
h1.SetYTitle("y");
h1.SetZTitle("dE");
h1.Draw("LEGO");
}

page->cd();

}

On Mon, 9 Mar 1998, Tadeusz Pytlos wrote:

> Hello Rene,
>
> On Sat, 7 Mar 1998, Rene Brun wrote:
>
> > Tadeusz Pytlos wrote:
> > >
> > > Hello Rooters,
> > > I would like to write small Event Display, but cannot solve
> > > some problems. I spent a lot of time, but results are small.
> > > Firstly, I don't know how create 3-dim scaterplot: x,y - position
> > > and dE - height (lego). In my below programme I find only how histogramm
> > > x and y from ntuples, but I need lego of dE on z-axis and
> > > not lego event number. I don't know
> > > also how link this scatterplot with predefined axis.
> > > Should h1 and h2 histos be 2 or 3 - dimensional? 3-dim histo
> > > still have failed me.
> >
> > You can see an example of a 3-d scatter-plot in the tutorial
> > example "ntuple1" at URL:
> > http://root.cern.ch/root/html/examples/ntuple1.C.html
> >
> Unfortunetly I cannot find right solution of my problem using this
> examples. 3-dim is too simple.
>
> >
> > > Next problem is how clear ntuples for next event display.
> > > I have event loop by j and I want to display event by event
> > > untill 5. Could you explain my problems?
> >
> > Well, again, I will encourage you to look at the ATLFast++ example.
> > See URL : http://root.cern.ch/root/Atlfast.html
> >
> > Another example of event display using Root is described
> > in the Rosebud package, see:
> > http://ganp03.in2p3.fr/nof/rosebud
> > Rene Brun
>
> Thank you for indications, but I'm not ready yet to use Atlfast. Not now,
> after some time. However, my problem should be much easer. Maybe working
> example below explain you what I want do to do. There are 2 events. Every
> has 3 coords. I would like the same picutre,but only on z axis should be
> dE. I cannot find how to reach it. The second problem is how to reset
> previous ntuple(or histo?) to receive next event.
> Best wishes,
> Tadeusz Pytlos
>
>
> Tadeusz Pytlos
> mailto:pytlos@fizwe5.fic.uni.lodz.pl
> Lodz, Poland
>
> // It's my working test macro cube.C
> {
> gROOT->Reset();
> page=new TCanvas("page","CUBE",0,0,500,700);
>
> TH2F *h1 = new TH2F("h1","CUBE",16,-100,100,16,-100,100);
> nt1 = new TNtuple("nt1","CUBE","x:y:dE");
>
> Int_t ans;
> Float_t x,y,dE;
> // 2 events
> Float_t xx[2][3]={-97.5,-71.5,-58.5,-97.5,71.5,-18.5};
> Float_t yy[2][3]={-84.5,-84.5,-71.5,-84.5,4.5,71.5};
> Float_t dEE[2][3]={13.5,18.25,17.5,3.5,10.51,11.5};
>
> gBenchmark->Start("cube");
> for (Int_t j=0; j<2;j++) {
> for (Int_t i=0; i<3;i++)
> {
> x=xx[j][i];
> y=yy[j][i];
> dE=dEE[j][i];
> nt1->Fill(x,y,dE);
> }
>
> page->cd();
> page->GetFrame()->SetFillColor(42);
> page->GetFrame()->SetBorderMode(-1);
> page->GetFrame()->SetBorderSize(5);
> h1.SetLineWidth(2);
> h1.SetXTitle("x");
> h1.SetYTitle("y");
> // h1.SetZTitle("dE");
> nt1.Draw("x:y>>h1");
> h1.Draw("LEGO");
>
> // ans=getchar();
> }
> gBenchmark->Show("dep");
>
> page->cd();
>
> }
>
>
>