Re: TMarker3DBox for zoom??

From: Rene Brun (Rene.Brun@cern.ch)
Date: Tue Mar 16 1999 - 16:57:05 MET


Tioukov Valeri wrote:
> 
> Hi rooters,
> 
> How to do the 3-d zoom?
> 
> I mean that if I have the CAVE 100x100x100 but I need to display just the
> zone 1x1x1 around the vertex with the coordinates x,y,z  - how to make
> the 3-d frame 1x1x1 with nesessary offsets where I can draw the
> tracks&hits?
> 
> The class TMarker3DBox(x,y,z,a,b,c) seems to be desiged for this but if I
> just do
> 
> root> TMarker3DBox *b=new TMarker3DBox(-21.,26.,27., 4.,4.,4.,0.,0.);
> root> b->Draw();
> 
> it makes just the empty canvase.
> 
> Is TMarker3DBox able just to show the small box inside the already
> existing plot of my big cave of I do something wrong?
> 

Hi Valeri,
To use the 3-d objects in a pad/canvas, you must create first a TView
object and set its range. In the macro below, you will find an example.
In an interactive viewer, you can call TView::SetRange using parameters
computed from an area selected with the mouse.
I can send you an example (ALICE event display class) illustrating
how this is done.

Federico Carminati will probably post to this mailing list the URL
for the ALICE classes.

Rene Brun

{
   gROOT->Reset();
   TH3F *h3 = new TH3F("h3","test fitz",5,-4,4,8,-4,4,5,0,20);
   for (Int_t i=0;i<100000;i++) {
      Float_t x = gRandom->Gaus(0,1);
      Float_t y = gRandom->Gaus(0,1);
      Float_t z = gRandom->Gaus(10,4);
      h3->Fill(x,y,z);
   }

   Int_t bin,ix,iy,iz;
   Float_t xmin,xmax,ymin,ymax,zmin,zmax,wmin,wmax,w;
   Int_t nbinsx = h3->GetXaxis()->GetNbins();
   Int_t nbinsy = h3->GetYaxis()->GetNbins();
   Int_t nbinsz = h3->GetZaxis()->GetNbins();
   
   //compute min and max of all cells
   wmin = wmax = 0;
   for (ix=1;ix<=nbinsx;ix++) {
      for (iy=1;iy<=nbinsy;iy++) {
         for (iz=1;iz<=nbinsz;iz++) {
            bin = h3->GetBin(ix,iy,iz);
            w = h3->GetBinContent(bin);
            if (w > wmax) wmax = w;
            if (w < wmin) wmin = w;
         }
      }
   }
   TCanvas *c1 = new TCanvas("c1");
   TView *view = new TView(1);
   view->SetRange(h3->GetXaxis()->GetXmin(), 
                  h3->GetYaxis()->GetXmin(),
                  h3->GetZaxis()->GetXmin(),
                  h3->GetXaxis()->GetXmax(),
                  h3->GetYaxis()->GetXmax(),
                  h3->GetZaxis()->GetXmax());

   //Draw TMarker3DBox with size proportional to cell content
   TMarker3DBox *m3;
   Float_t scale;
   for (ix=1;ix<=nbinsx;ix++) {
      xmin = h3->GetXaxis()->GetBinLowEdge(ix);
      xmax = xmin + h3->GetXaxis()->GetBinWidth(ix);
      for (iy=1;iy<=nbinsy;iy++) {
         ymin = h3->GetYaxis()->GetBinLowEdge(iy);
         ymax = ymin + h3->GetYaxis()->GetBinWidth(iy);
         for (iz=1;iz<=nbinsz;iz++) {
            zmin = h3->GetZaxis()->GetBinLowEdge(iz);
            zmax = zmin + h3->GetZaxis()->GetBinWidth(iz);
            bin = h3->GetBin(ix,iy,iz);
            w = h3->GetBinContent(bin);
            scale = (w-wmin)/(wmax-wmin);
            m3 = new
TMarker3DBox(0.5*(xmin+xmax),0.5*(ymin+ymax),0.5*(zmin+zmax),
              
scale*(xmax-xmin),scale*(ymax-ymin),scale*(zmax-zmin),0,0);
            m3->SetLineColor(h3->GetMarkerColor());
            m3->Draw();
         }
      }
   }
      
}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:43:30 MET