geodemo.C

Go to the documentation of this file.
00001 // GUI to draw the geometry shapes
00002 // Author: M.Gheata  06/16/03
00003 Bool_t comments = kTRUE;
00004 Bool_t raytracing = kFALSE;
00005 Bool_t rotate = kFALSE;
00006 Bool_t axis = kTRUE;
00007 
00008 //______________________________________________________________________________
00009 void geodemo ()
00010 {
00011 // root[0] .x geodemo.C
00012 // root[1] box();   //draw a TGeoBBox with description
00013 //
00014 // The box can be divided on one axis.
00015 //
00016 // root[2] box(iaxis, ndiv, start, step);
00017 //
00018 // where: iaxis = 1,2 or 3, meaning (X,Y,Z) or (Rxy, phi, Z) depending on shape type
00019 //        ndiv  = number of slices
00020 //        start = starting position (must be in shape range)
00021 //        step  = division step
00022 // If step=0, all range of a given axis will be divided
00023 // 
00024 // The same can procedure can be performed for visualizing other shapes.
00025 // When drawing one shape after another, the old geometry/canvas will be deleted.
00026    gSystem->Load("libGeom");
00027    TString dir = gSystem->UnixPathName(gInterpreter->GetCurrentMacroName());
00028    dir.ReplaceAll("geodemo.C","");
00029    dir.ReplaceAll("/./","/");
00030    gROOT->LoadMacro(dir+"rootgeom.C");
00031    bar = new TControlBar("vertical", "TGeo shapes",10,10);
00032    bar->AddButton("How to run  ","help()","Instructions for running this macro"); 
00033    bar->AddButton("ROOTgeom    ","rootgeom()","A simple geometry example.");
00034    bar->AddButton("Arb8        ","arb8()","An arbitrary polyedron defined by vertices (max 8) sitting on 2 parallel planes");
00035    bar->AddButton("Box         ","box()","A box shape.");
00036    bar->AddButton("Composite   ","composite()","A composite shape");
00037    bar->AddButton("Cone        ","cone()","A conical tube");
00038    bar->AddButton("Cone segment","coneseg()","A conical segment");
00039    bar->AddButton("Cut tube    ","ctub()","A cut tube segment");
00040    bar->AddButton("Eliptical tube","eltu()","An eliptical tube");
00041    bar->AddButton("Extruded poly","xtru()","A general polygone extrusion");
00042    bar->AddButton("Hyperboloid  ","hype()","A hyperboloid"); 
00043    bar->AddButton("Paraboloid  ","parab()","A paraboloid"); 
00044    bar->AddButton("Polycone    ","pcon()","A polycone shape");
00045    bar->AddButton("Polygone    ","pgon()","A polygone"); 
00046    bar->AddButton("Parallelipiped","para()","A parallelipiped shape");
00047    bar->AddButton("Sphere      ","sphere()","A spherical sector");
00048    bar->AddButton("Trd1        ","trd1()","A trapezoid with dX varying with Z");
00049    bar->AddButton("Trd2        ","trd2()","A trapezoid with both dX and dY varying with Z");
00050    bar->AddButton("Trapezoid   ","trap()","A general trapezoid");
00051    bar->AddButton("Torus       ","torus()","A toroidal segment");
00052    bar->AddButton("Tube        ","tube()","A tube with inner and outer radius");
00053    bar->AddButton("Tube segment","tubeseg()","A tube segment");
00054    bar->AddButton("Twisted trap","gtra()","A twisted trapezoid");
00055    bar->AddButton("Aligned (ideal)","ideal()","An ideal (un-aligned) geometry");
00056    bar->AddButton("Un-aligned","align()","Some alignment operation");
00057    bar->AddButton("RAY-TRACE ON/OFF","raytrace()","Toggle ray-tracing mode");
00058    bar->AddButton("COMMENTS  ON/OFF","comments = !comments;","Toggle explanations pad ON/OFF");
00059    bar->AddButton("AXES ON/OFF","axes()","Toggle axes ON/OFF");
00060    bar->AddButton("AUTOROTATE ON/OFF","autorotate()","Toggle autorotation ON/OFF");
00061    bar->Show();
00062    gROOT->SaveContext();
00063    gRandom = new TRandom3();
00064 }
00065 
00066 //______________________________________________________________________________
00067 autorotate()
00068 {
00069    rotate = !rotate;
00070    if (!rotate) {
00071       gROOT->SetInterrupt(kTRUE);
00072       return;
00073    }   
00074    if (!gPad) return;
00075    TView *view = gPad->GetView();
00076    if (!view) return;
00077    if (!gGeoManager) return;
00078    TVirtualGeoPainter *painter = gGeoManager->GetGeomPainter();
00079    if (!painter) return;
00080    Double_t longit = view->GetLongitude();
00081    Double_t lat = view->GetLatitude();
00082    Double_t psi = view->GetPsi();
00083    Double_t dphi = 1.;
00084    Int_t i,irep;
00085    TProcessEventTimer *timer = new TProcessEventTimer(5);
00086    gROOT->SetInterrupt(kFALSE);
00087    while (rotate) {
00088       if (timer->ProcessEvents()) break;
00089       if (gROOT->IsInterrupted()) break;
00090       longit += dphi;
00091       if (longit>360) longit -= 360.;
00092       if (!gPad) {
00093          rotate = kFALSE;
00094          return;
00095       } 
00096       view = gPad->GetView();  
00097       if (!view) {
00098          rotate = kFALSE;
00099          return;
00100       } 
00101       view->SetView(longit,view->GetLatitude(),view->GetPsi(),irep);
00102       gPad->Modified();
00103       gPad->Update();
00104    } 
00105    delete timer;     
00106 }
00107 
00108 //______________________________________________________________________________
00109 void axes()
00110 {
00111    axis = !axis;
00112    if (!gPad) return;
00113    TView *view = gPad->GetView();
00114    view->ShowAxis();
00115 }   
00116 
00117 //______________________________________________________________________________
00118 void rgeom()
00119 {
00120    gROOT->GetListOfCanvases()->Delete();
00121    rootgeom();
00122    Bool_t is_raytracing = gGeoManager->GetGeomPainter()->IsRaytracing();
00123    if (is_raytracing != raytracing) {
00124       gGeoManager->GetTopVolume()->Draw();
00125       gGeoManager->GetGeomPainter()->SetRaytracing(raytracing);
00126       gPad->Modified();
00127       gPad->Update();
00128    }   
00129 }   
00130 
00131 //______________________________________________________________________________
00132 void box(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00133 {
00134    gROOT->GetListOfCanvases()->Delete();
00135    if (iaxis<0 || iaxis>3) {
00136       printf("Wrong division axis. Range is 1-3.\n");
00137       return;
00138    }   
00139    TCanvas *c = new TCanvas("box shape", "A simple box", 700,1000);
00140    if (comments) {
00141       c->Divide(1,2,0,0);
00142       c->cd(2);
00143       gPad->SetPad(0,0,1,0.4);
00144       c->cd(1);
00145       gPad->SetPad(0,0.4,1,1);
00146    }   
00147    if (gGeoManager) delete gGeoManager;
00148    new TGeoManager("box", "poza1");
00149    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00150    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00151    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00152    gGeoManager->SetTopVolume(top);
00153    TGeoVolume *vol = gGeoManager->MakeBox("BOX",med, 20,30,40);
00154    vol->SetLineColor(randomColor());
00155    vol->SetLineWidth(2);
00156    top->AddNode(vol,1);
00157    if (iaxis) {
00158       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00159       if (!slice) return;
00160       slice->SetLineColor(randomColor());
00161    }
00162    gGeoManager->CloseGeometry();
00163    gGeoManager->SetNsegments(80);
00164    top->Draw();
00165    MakePicture();
00166    if (!comments) return;
00167    c->cd(2);
00168    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00169    pt->SetLineColor(1);
00170    TGeoBBox *box = (TGeoBBox*)(vol->GetShape());
00171    TText *text = pt->AddText("TGeoBBox - box class");
00172    text->SetTextColor(2);
00173    AddText(pt,"fDX",box->GetDX(),"half length in X");
00174    AddText(pt,"fDY",box->GetDY(),"half length in Y");
00175    AddText(pt,"fDZ",box->GetDZ(),"half length in Z");
00176    AddText(pt,"fOrigin[0]",(box->GetOrigin())[0],"box origin on X");
00177    AddText(pt,"fOrigin[1]",(box->GetOrigin())[1],"box origin on Y");
00178    AddText(pt,"fOrigin[2]",(box->GetOrigin())[2],"box origin on Z");
00179    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00180    pt->AddText("Execute: box(iaxis, ndiv, start, step) to divide this.");
00181    pt->AddText("----- IAXIS can be 1, 2 or 3 (X, Y, Z)");
00182    pt->AddText("----- NDIV must be a positive integer");
00183    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
00184    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
00185    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
00186    pt->AddText(" ");
00187    pt->SetTextSize(0.044);
00188    pt->SetAllWith("-----","color",2);
00189    pt->SetAllWith("-----","font",72);
00190    pt->SetAllWith("-----","size",0.04);
00191    pt->SetAllWith("Execute","color",4);
00192    pt->SetTextAlign(12);
00193    pt->Draw();
00194 //   SavePicture("box",c,vol,iaxis,step);
00195    c->cd(1);
00196    gROOT->SetInterrupt(kTRUE);
00197 }
00198 
00199 //______________________________________________________________________________
00200 void para(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00201 {
00202    gROOT->GetListOfCanvases()->Delete();
00203    TCanvas *c = new TCanvas("para shape", "A parallelipiped", 700,1000);
00204    if (comments) {
00205       c->Divide(1,2,0,0);
00206       c->cd(2);
00207       gPad->SetPad(0,0,1,0.4);
00208       c->cd(1);
00209       gPad->SetPad(0,0.4,1,1);
00210    }   
00211    if (gGeoManager) delete gGeoManager;
00212    new TGeoManager("para", "poza1");
00213    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00214    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00215    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00216    gGeoManager->SetTopVolume(top);
00217    TGeoVolume *vol = gGeoManager->MakePara("PARA",med, 20,30,40,30,15,30);
00218    vol->SetLineColor(randomColor());
00219    vol->SetLineWidth(2);
00220    top->AddNode(vol,1);
00221    if (iaxis) {
00222       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00223       if (!slice) return;
00224       slice->SetLineColor(randomColor());
00225    }
00226    gGeoManager->CloseGeometry();
00227    gGeoManager->SetNsegments(80);
00228    top->Draw();
00229    MakePicture();
00230    if (!comments) return;
00231    c->cd(2);
00232    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00233    pt->SetLineColor(1);
00234    TGeoPara *para = (TGeoPara*)(vol->GetShape());
00235    TText *text = pt->AddText("TGeoPara - parallelipiped class");
00236    text->SetTextColor(2);
00237    AddText(pt,"fX",para->GetX(),"half length in X");
00238    AddText(pt,"fY",para->GetY(),"half length in Y");
00239    AddText(pt,"fZ",para->GetZ(),"half length in Z");
00240    AddText(pt,"fAlpha",para->GetAlpha(),"angle about Y of the Z bases");
00241    AddText(pt,"fTheta",para->GetTheta(),"inclination of para axis about Z");
00242    AddText(pt,"fPhi",para->GetPhi(),"phi angle of para axis");
00243    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00244    pt->AddText("Execute: para(iaxis, ndiv, start, step) to divide this.");
00245    pt->AddText("----- IAXIS can be 1, 2 or 3 (X, Y, Z)");
00246    pt->AddText("----- NDIV must be a positive integer");
00247    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
00248    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
00249    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
00250    pt->AddText(" ");
00251    pt->SetTextSize(0.044);
00252    pt->SetAllWith("-----","color",2);
00253    pt->SetAllWith("-----","font",72);
00254    pt->SetAllWith("-----","size",0.04);
00255    pt->SetAllWith("Execute","color",4);
00256    pt->SetTextAlign(12);
00257    pt->Draw();
00258    c->cd(1);
00259 //   SavePicture("para",c,vol,iaxis,step);
00260 }
00261 
00262 //______________________________________________________________________________
00263 void tube(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00264 {
00265    gROOT->GetListOfCanvases()->Delete();
00266    if (iaxis<0 || iaxis>3) {
00267       printf("Wrong division axis. Range is 1-3.\n");
00268       return;
00269    }   
00270    TCanvas *c = new TCanvas("tube shape", "A tube", 700,1000);
00271    if (comments) {
00272       c->Divide(1,2,0,0);
00273       c->cd(2);
00274       gPad->SetPad(0,0,1,0.4);
00275       c->cd(1);
00276       gPad->SetPad(0,0.4,1,1);
00277    }   
00278    if (gGeoManager) delete gGeoManager;
00279    new TGeoManager("tube", "poza2");
00280    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00281    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00282    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00283    gGeoManager->SetTopVolume(top);
00284    TGeoVolume *vol = gGeoManager->MakeTube("TUBE",med, 20,30,40);
00285    vol->SetLineColor(randomColor());
00286    vol->SetLineWidth(2);
00287    top->AddNode(vol,1);
00288    if (iaxis) {
00289       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00290       if (!slice) return;
00291       slice->SetLineColor(randomColor());
00292    }
00293    gGeoManager->CloseGeometry();
00294 //   gGeoManager->SetNsegments(40);
00295    gGeoManager->SetNsegments(80);
00296    top->Draw();
00297    MakePicture();
00298    if (!comments) return;
00299    c->cd(2);
00300    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00301    pt->SetLineColor(1);
00302    TGeoTube *tube = (TGeoTube*)(vol->GetShape());
00303    TText *text = pt->AddText("TGeoTube - tube class");
00304    text->SetTextColor(2);
00305    AddText(pt,"fRmin",tube->GetRmin(),"minimum radius");
00306    AddText(pt,"fRmax",tube->GetRmax(),"maximum radius");
00307    AddText(pt,"fDZ",  tube->GetDZ(),  "half length in Z");
00308    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00309    pt->AddText("Execute: tube(iaxis, ndiv, start, step) to divide this.");
00310    pt->AddText("----- IAXIS can be 1, 2 or 3 (Rxy, Phi, Z)");
00311    pt->AddText("----- NDIV must be a positive integer");
00312    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
00313    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
00314    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
00315    pt->AddText(" ");
00316    pt->SetAllWith("-----","color",2);
00317    pt->SetAllWith("-----","font",72);
00318    pt->SetAllWith("-----","size",0.04);
00319    pt->SetAllWith("Execute","color",4);
00320    pt->SetTextAlign(12);
00321    pt->SetTextSize(0.044);
00322    pt->Draw();
00323    c->cd(1);
00324 //   SavePicture("tube",c,vol,iaxis,step);
00325 }
00326 
00327 //______________________________________________________________________________
00328 void tubeseg(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00329 {
00330    gROOT->GetListOfCanvases()->Delete();
00331    if (iaxis<0 || iaxis>3) {
00332       printf("Wrong division axis. Range is 1-3.\n");
00333       return;
00334    }   
00335    TCanvas *c = new TCanvas("tubeseg shape", "A tube segment ", 700,1000);
00336    if (comments) {
00337       c->Divide(1,2,0,0);
00338       c->cd(2);
00339       gPad->SetPad(0,0,1,0.4);
00340       c->cd(1);
00341       gPad->SetPad(0,0.4,1,1);
00342    }   
00343    if (gGeoManager) delete gGeoManager;
00344    new TGeoManager("tubeseg", "poza3");
00345    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00346    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00347    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00348    gGeoManager->SetTopVolume(top);
00349    TGeoVolume *vol = gGeoManager->MakeTubs("TUBESEG",med, 20,30,40,-30,270);
00350    vol->SetLineColor(randomColor());
00351    if (iaxis) {
00352       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00353       if (!slice) return;
00354       slice->SetLineColor(randomColor());
00355    }
00356    vol->SetLineWidth(2);
00357    top->AddNode(vol,1);
00358    gGeoManager->CloseGeometry();
00359 //   gGeoManager->SetNsegments(40);
00360    gGeoManager->SetNsegments(80);
00361    top->Draw();
00362    MakePicture();
00363    if (!comments) return;
00364    c->cd(2);
00365    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00366    pt->SetLineColor(1);
00367    TGeoTubeSeg *tubeseg = (TGeoTubeSeg*)(vol->GetShape());
00368    TText *text = pt->AddText("TGeoTubeSeg - tube segment class");
00369    text->SetTextColor(2);
00370    AddText(pt,"fRmin",tubeseg->GetRmin(),"minimum radius");
00371    AddText(pt,"fRmax",tubeseg->GetRmax(),"maximum radius");
00372    AddText(pt,"fDZ",  tubeseg->GetDZ(),  "half length in Z");
00373    AddText(pt,"fPhi1",tubeseg->GetPhi1(),"first phi limit");
00374    AddText(pt,"fPhi2",tubeseg->GetPhi2(),"second phi limit");  
00375    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00376    pt->AddText("Execute: tubeseg(iaxis, ndiv, start, step) to divide this.");
00377    pt->AddText("----- IAXIS can be 1, 2 or 3 (Rxy, Phi, Z)");
00378    pt->AddText("----- NDIV must be a positive integer");
00379    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
00380    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
00381    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
00382    pt->AddText(" ");
00383    pt->SetAllWith("-----","color",2);
00384    pt->SetAllWith("-----","font",72);
00385    pt->SetAllWith("-----","size",0.04);
00386    pt->SetAllWith("Execute","color",4);
00387    pt->SetTextAlign(12);
00388    pt->SetTextSize(0.044);
00389    pt->Draw();
00390    c->cd(1);
00391 //   SavePicture("tubeseg",c,vol,iaxis,step);
00392 }
00393 
00394 //______________________________________________________________________________
00395 void ctub(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00396 {
00397    gROOT->GetListOfCanvases()->Delete();
00398    if (iaxis<0 || iaxis>2) {
00399       printf("Wrong division axis. Range is 1-2.\n");
00400       return;
00401    }   
00402    TCanvas *c = new TCanvas("ctub shape", "A cut tube segment ", 700,1000);
00403    if (comments) {
00404       c->Divide(1,2,0,0);
00405       c->cd(2);
00406       gPad->SetPad(0,0,1,0.4);
00407       c->cd(1);
00408       gPad->SetPad(0,0.4,1,1);
00409    }   
00410    if (gGeoManager) delete gGeoManager;
00411    new TGeoManager("ctub", "poza3");
00412    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00413    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00414    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00415    gGeoManager->SetTopVolume(top);
00416    Double_t theta = 160.*TMath::Pi()/180.;
00417    Double_t phi   = 30.*TMath::Pi()/180.;
00418    Double_t nlow[3];
00419    nlow[0] = TMath::Sin(theta)*TMath::Cos(phi);
00420    nlow[1] = TMath::Sin(theta)*TMath::Sin(phi);
00421    nlow[2] = TMath::Cos(theta);
00422    theta = 20.*TMath::Pi()/180.;
00423    phi   = 60.*TMath::Pi()/180.;
00424    Double_t nhi[3];
00425    nhi[0] = TMath::Sin(theta)*TMath::Cos(phi);
00426    nhi[1] = TMath::Sin(theta)*TMath::Sin(phi);
00427    nhi[2] = TMath::Cos(theta);
00428    TGeoVolume *vol = gGeoManager->MakeCtub("CTUB",med, 20,30,40,-30,250, nlow[0], nlow[1], nlow[2], nhi[0],nhi[1],nhi[2]);
00429    vol->SetLineColor(randomColor());
00430    if (iaxis) {
00431       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00432       if (!slice) return;
00433       slice->SetLineColor(randomColor());
00434    }
00435    vol->SetLineWidth(2);
00436    top->AddNode(vol,1);
00437    gGeoManager->CloseGeometry();
00438 //   gGeoManager->SetNsegments(40);
00439    gGeoManager->SetNsegments(80);
00440    top->Draw();
00441    MakePicture();
00442    if (!comments) return;
00443    c->cd(2);
00444    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00445    pt->SetLineColor(1);
00446    TGeoTubeSeg *tubeseg = (TGeoTubeSeg*)(vol->GetShape());
00447    TText *text = pt->AddText("TGeoTubeSeg - tube segment class");
00448    text->SetTextColor(2);
00449    AddText(pt,"fRmin",tubeseg->GetRmin(),"minimum radius");
00450    AddText(pt,"fRmax",tubeseg->GetRmax(),"maximum radius");
00451    AddText(pt,"fDZ",  tubeseg->GetDZ(),  "half length in Z");
00452    AddText(pt,"fPhi1",tubeseg->GetPhi1(),"first phi limit");
00453    AddText(pt,"fPhi2",tubeseg->GetPhi2(),"second phi limit");  
00454    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00455    pt->AddText(" ");
00456    pt->SetTextAlign(12);
00457    pt->SetTextSize(0.044);
00458    pt->Draw();
00459    c->cd(1);
00460 //   SavePicture("tubeseg",c,vol,iaxis,step);
00461 }
00462 
00463 //______________________________________________________________________________
00464 void cone(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00465 {
00466    gROOT->GetListOfCanvases()->Delete();
00467    if (iaxis<0 || iaxis>3) {
00468       printf("Wrong division axis. Range is 1-3.\n");
00469       return;
00470    }   
00471    if (iaxis==1) {
00472       printf("cannot divide cone on Rxy\n");
00473       return;
00474    }   
00475    TCanvas *c = new TCanvas("cone shape", "A cone", 700,1000);
00476    if (comments) {
00477       c->Divide(1,2,0,0);
00478       c->cd(2);
00479       gPad->SetPad(0,0,1,0.4);
00480       c->cd(1);
00481       gPad->SetPad(0,0.4,1,1);
00482    }   
00483    if (gGeoManager) delete gGeoManager;
00484    new TGeoManager("cone", "poza4");
00485    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00486    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00487    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00488    gGeoManager->SetTopVolume(top);
00489    TGeoVolume *vol = gGeoManager->MakeCone("CONE",med, 40,10,20,35,45);
00490    vol->SetLineColor(randomColor());
00491    vol->SetLineWidth(2);
00492    if (iaxis) {
00493       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00494       if (!slice) return;
00495       slice->SetLineColor(randomColor());
00496    }
00497    top->AddNode(vol,1);
00498    gGeoManager->CloseGeometry();
00499    gGeoManager->SetNsegments(80);
00500    top->Draw();
00501    MakePicture();
00502    if (!comments) return;
00503    c->cd(2);
00504    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00505    pt->SetLineColor(1);
00506    TGeoCone *cone = (TGeoCone*)(vol->GetShape());
00507    TText *text = pt->AddText("TGeoCone - cone class");
00508    text->SetTextColor(2);
00509    AddText(pt,"fDZ",  cone->GetDZ(),    "half length in Z");
00510    AddText(pt,"fRmin1",cone->GetRmin1(),"inner radius at -dz");
00511    AddText(pt,"fRmax1",cone->GetRmax1(),"outer radius at -dz");
00512    AddText(pt,"fRmin2",cone->GetRmin2(),"inner radius at +dz");
00513    AddText(pt,"fRmax2",cone->GetRmax2(),"outer radius at +dz");
00514    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00515    pt->AddText("Execute: cone(iaxis, ndiv, start, step) to divide this.");
00516    pt->AddText("----- IAXIS can be 2 or 3 (Phi, Z)");
00517    pt->AddText("----- NDIV must be a positive integer");
00518    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
00519    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
00520    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
00521    pt->AddText(" ");
00522    pt->SetAllWith("-----","color",2);
00523    pt->SetAllWith("-----","font",72);
00524    pt->SetAllWith("-----","size",0.04);
00525    pt->SetAllWith("Execute","color",4);
00526    pt->SetTextAlign(12);
00527    pt->SetTextSize(0.044);
00528    pt->Draw();
00529    c->cd(1);
00530 //   SavePicture("cone",c,vol,iaxis,step);
00531 }
00532 
00533 //______________________________________________________________________________
00534 void coneseg(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00535 {
00536    gROOT->GetListOfCanvases()->Delete();
00537    if (iaxis<0 || iaxis>3) {
00538       printf("Wrong division axis. Range is 1-3.\n");
00539       return;
00540    }   
00541    TCanvas *c = new TCanvas("coneseg shape", "A cone segment", 700,1000);
00542    if (comments) {
00543       c->Divide(1,2,0,0);
00544       c->cd(2);
00545       gPad->SetPad(0,0,1,0.4);
00546       c->cd(1);
00547       gPad->SetPad(0,0.4,1,1);
00548    }   
00549    if (gGeoManager) delete gGeoManager;
00550    new TGeoManager("coneseg", "poza5");
00551    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00552    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00553    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00554    gGeoManager->SetTopVolume(top);
00555    TGeoVolume *vol = gGeoManager->MakeCons("CONESEG",med, 40,30,40,10,20,-30,250);
00556    vol->SetLineColor(randomColor());
00557 //   vol->SetLineWidth(2);
00558    top->AddNode(vol,1);
00559    if (iaxis) {
00560       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00561       if (!slice) return;
00562       slice->SetLineColor(randomColor());
00563    }
00564    gGeoManager->CloseGeometry();
00565    gGeoManager->SetNsegments(80);
00566    top->Draw();
00567    MakePicture();
00568    if (!comments) return;
00569    c->cd(2);
00570    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00571    pt->SetLineColor(1);
00572    TGeoConeSeg *coneseg = (TGeoConeSeg*)(vol->GetShape());
00573    TText *text = pt->AddText("TGeoConeSeg - coneseg class");
00574    text->SetTextColor(2);
00575    AddText(pt,"fDZ",  coneseg->GetDZ(),    "half length in Z");
00576    AddText(pt,"fRmin1",coneseg->GetRmin1(),"inner radius at -dz");
00577    AddText(pt,"fRmax1",coneseg->GetRmax1(),"outer radius at -dz");
00578    AddText(pt,"fRmin2",coneseg->GetRmin1(),"inner radius at +dz");
00579    AddText(pt,"fRmax2",coneseg->GetRmax1(),"outer radius at +dz");
00580    AddText(pt,"fPhi1",coneseg->GetPhi1(),"first phi limit");
00581    AddText(pt,"fPhi2",coneseg->GetPhi2(),"second phi limit"); 
00582    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00583    pt->AddText("Execute: coneseg(iaxis, ndiv, start, step) to divide this.");
00584    pt->AddText("----- IAXIS can be 2 or 3 (Phi, Z)");
00585    pt->AddText("----- NDIV must be a positive integer");
00586    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
00587    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
00588    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
00589    pt->AddText(" ");
00590    pt->SetAllWith("-----","color",2);
00591    pt->SetAllWith("-----","font",72);
00592    pt->SetAllWith("-----","size",0.04);
00593    pt->SetAllWith("Execute","color",4);
00594    pt->SetTextAlign(12);
00595    pt->SetTextSize(0.044);
00596    pt->Draw();
00597    c->cd(1);
00598 //   SavePicture("coneseg",c,vol,iaxis,step);
00599 }
00600 
00601 //______________________________________________________________________________
00602 void eltu(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00603 {
00604    gROOT->GetListOfCanvases()->Delete();
00605    TCanvas *c = new TCanvas("eltu shape", "An Elliptical tube", 700,1000);
00606    if (comments) {
00607       c->Divide(1,2,0,0);
00608       c->cd(2);
00609       gPad->SetPad(0,0,1,0.4);
00610       c->cd(1);
00611       gPad->SetPad(0,0.4,1,1);
00612    }   
00613    if (gGeoManager) delete gGeoManager;
00614    new TGeoManager("eltu", "poza6");
00615    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00616    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00617    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00618    gGeoManager->SetTopVolume(top);
00619    TGeoVolume *vol = gGeoManager->MakeEltu("ELTU",med, 30,10,40);
00620    vol->SetLineColor(randomColor());
00621 //   vol->SetLineWidth(2);
00622    top->AddNode(vol,1);
00623    if (iaxis) {
00624       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00625       if (!slice) return;
00626       slice->SetLineColor(randomColor());
00627    }
00628    gGeoManager->CloseGeometry();
00629    gGeoManager->SetNsegments(80);
00630    top->Draw();
00631    MakePicture();
00632    if (!comments) return;
00633    c->cd(2);
00634    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00635    pt->SetLineColor(1);
00636    TGeoEltu *eltu = (TGeoEltu*)(vol->GetShape());
00637    TText *text = pt->AddText("TGeoEltu - eltu class");
00638    text->SetTextColor(2);
00639    AddText(pt,"fA",eltu->GetA(), "semi-axis along x");
00640    AddText(pt,"fB",eltu->GetB(), "semi-axis along y");
00641    AddText(pt,"fDZ", eltu->GetDZ(),  "half length in Z");
00642    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00643    pt->AddText("Execute: eltu(iaxis, ndiv, start, step) to divide this.");
00644    pt->AddText("----- IAXIS can be 2 or 3 (Phi, Z)");
00645    pt->AddText("----- NDIV must be a positive integer");
00646    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
00647    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
00648    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
00649    pt->AddText(" ");
00650    pt->SetAllWith("-----","color",2);
00651    pt->SetAllWith("-----","font",72);
00652    pt->SetAllWith("-----","size",0.04);
00653    pt->SetAllWith("Execute","color",4);
00654    pt->SetTextAlign(12);
00655    pt->SetTextSize(0.044);
00656    pt->Draw();
00657    c->cd(1);
00658 //   SavePicture("eltu",c,vol,iaxis,step);
00659 }
00660 
00661 //______________________________________________________________________________
00662 void sphere(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00663 {
00664    gROOT->GetListOfCanvases()->Delete();
00665    if (iaxis!=0) {
00666       printf("Cannot divide spheres\n");
00667       return;
00668    }   
00669    TCanvas *c = new TCanvas("Sphere shap", "A spherical sector", 700,1000);
00670    if (comments) {
00671       c->Divide(1,2,0,0);
00672       c->cd(2);
00673       gPad->SetPad(0,0,1,0.4);
00674       c->cd(1);
00675       gPad->SetPad(0,0.4,1,1);
00676    }   
00677    if (gGeoManager) delete gGeoManager;
00678    new TGeoManager("sphere", "poza7");
00679    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00680    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00681    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00682    gGeoManager->SetTopVolume(top);
00683    TGeoVolume *vol = gGeoManager->MakeSphere("SPHERE",med, 30,40,60,120,30,240);
00684    vol->SetLineColor(randomColor());
00685    vol->SetLineWidth(2);
00686    top->AddNode(vol,1);
00687    if (iaxis) {
00688       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00689       if (!slice) return;
00690       slice->SetLineColor(randomColor());
00691    }
00692    gGeoManager->CloseGeometry();
00693    gGeoManager->SetNsegments(80);
00694    top->Draw();
00695    MakePicture();
00696    if (!comments) return;
00697    c->cd(2);
00698    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00699    pt->SetLineColor(1);
00700    TGeoSphere *sphere = (TGeoSphere*)(vol->GetShape());
00701    TText *text = pt->AddText("TGeoSphere- sphere class");
00702    text->SetTextColor(2);
00703    AddText(pt,"fRmin",sphere->GetRmin(),"inner radius");
00704    AddText(pt,"fRmax",sphere->GetRmax(),"outer radius");
00705    AddText(pt,"fTheta1",sphere->GetTheta1(),"lower theta limit");
00706    AddText(pt,"fTheta2",sphere->GetTheta2(),"higher theta limit");
00707    AddText(pt,"fPhi1",sphere->GetPhi1(),"lower phi limit");
00708    AddText(pt,"fPhi2",sphere->GetPhi2(),"higher phi limit"); 
00709    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00710    pt->AddText(" ");
00711    pt->SetTextSize(0.044);
00712    pt->Draw();
00713    c->cd(1);
00714 //   SavePicture("sphere",c,vol,iaxis,step);
00715 }
00716 
00717 //______________________________________________________________________________
00718 void torus(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00719 {
00720    gROOT->GetListOfCanvases()->Delete();
00721    if (iaxis!=0) {
00722       printf("Cannot divide a torus\n");
00723       return;
00724    }   
00725    TCanvas *c = new TCanvas("torus shape", "A toroidal segment", 700,1000);
00726    if (comments) {
00727       c->Divide(1,2,0,0);
00728       c->cd(2);
00729       gPad->SetPad(0,0,1,0.4);
00730       c->cd(1);
00731       gPad->SetPad(0,0.4,1,1);
00732    }   
00733    if (gGeoManager) delete gGeoManager;
00734    new TGeoManager("torus", "poza2");
00735    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00736    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00737    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00738    gGeoManager->SetTopVolume(top);
00739    TGeoVolume *vol = gGeoManager->MakeTorus("TORUS",med, 40,20,25,0,270);
00740    vol->SetLineColor(randomColor());
00741    top->AddNode(vol,1);
00742    if (iaxis) {
00743       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00744       if (!slice) return;
00745       slice->SetLineColor(2);
00746    }
00747    gGeoManager->CloseGeometry();
00748    gGeoManager->SetNsegments(80);
00749    top->Draw();
00750    MakePicture();
00751    if (!comments) return;
00752    c->cd(2);
00753    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00754    pt->SetLineColor(1);
00755    TGeoTorus *tor = (TGeoTorus*)(vol->GetShape());
00756    TText *text = pt->AddText("TGeoTorus - torus class");
00757    text->SetTextColor(2);
00758    AddText(pt,"fR",tor->GetR(),"radius of the ring");
00759    AddText(pt,"fRmin",tor->GetRmin(),"minimum radius");
00760    AddText(pt,"fRmax",tor->GetRmax(),"maximum radius");
00761    AddText(pt,"fPhi1",  tor->GetPhi1(),  "starting phi angle");
00762    AddText(pt,"fDphi",  tor->GetDphi(),  "phi range");
00763    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00764    pt->AddText(" ");
00765    pt->SetTextSize(0.044);
00766    pt->Draw();
00767    c->cd(1);
00768 }        
00769 
00770 //______________________________________________________________________________
00771 void trd1(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00772 {
00773    gROOT->GetListOfCanvases()->Delete();
00774    if (iaxis<0 || iaxis>3) {
00775       printf("Wrong division axis. Range is 1-3.\n");
00776       return;
00777    }   
00778    if (iaxis==1) {
00779       printf("Cannot divide trd1 on X axis\n");
00780       return;
00781    }   
00782    
00783    TCanvas *c = new TCanvas("trd1 shape", "A trapezoid with dX varying", 700,1000);
00784    if (comments) {
00785       c->Divide(1,2,0,0);
00786       c->cd(2);
00787       gPad->SetPad(0,0,1,0.4);
00788       c->cd(1);
00789       gPad->SetPad(0,0.4,1,1);
00790    }   
00791    if (gGeoManager) delete gGeoManager;
00792    new TGeoManager("trd1", "poza8");
00793    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00794    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00795    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00796    gGeoManager->SetTopVolume(top);
00797    TGeoVolume *vol = gGeoManager->MakeTrd1("Trd1",med, 10,20,30,40);
00798    vol->SetLineColor(randomColor());
00799    vol->SetLineWidth(2);
00800    top->AddNode(vol,1);
00801    if (iaxis) {
00802       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00803       if (!slice) return;
00804       slice->SetLineColor(randomColor());
00805    }
00806    gGeoManager->CloseGeometry();
00807    gGeoManager->SetNsegments(80);
00808    top->Draw();
00809    MakePicture();
00810    if (!comments) return;
00811    c->cd(2);
00812    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00813    pt->SetLineColor(1);
00814    TGeoTrd1 *trd1 = (TGeoTrd1*)(vol->GetShape());
00815    TText *text = pt->AddText("TGeoTrd1 - Trd1 class");
00816    text->SetTextColor(2);
00817    AddText(pt,"fDx1",trd1->GetDx1(),"half length in X at lower Z surface(-dz)");
00818    AddText(pt,"fDx2",trd1->GetDx2(),"half length in X at higher Z surface(+dz)");
00819    AddText(pt,"fDy",trd1->GetDy(),"half length in Y");
00820    AddText(pt,"fDz",trd1->GetDz(),"half length in Z");
00821    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
00822    pt->AddText("Execute: trd1(iaxis, ndiv, start, step) to divide this.");
00823    pt->AddText("----- IAXIS can be 2 or 3 (Y, Z)");
00824    pt->AddText("----- NDIV must be a positive integer");
00825    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
00826    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
00827    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
00828    pt->AddText(" ");
00829    pt->SetAllWith("-----","color",2);
00830    pt->SetAllWith("-----","font",72);
00831    pt->SetAllWith("-----","size",0.04);
00832    pt->SetAllWith("Execute","color",4);
00833    pt->SetTextAlign(12);
00834    pt->SetTextSize(0.044);
00835    pt->Draw();
00836    c->cd(1);
00837 //   SavePicture("trd1",c,vol,iaxis,step);
00838 }
00839 
00840 //______________________________________________________________________________
00841 void parab()
00842 {
00843    gROOT->GetListOfCanvases()->Delete();
00844    TCanvas *c = new TCanvas("parab shape", "A paraboloid segment", 700,1000);
00845    if (comments) {
00846       c->Divide(1,2,0,0);
00847       c->cd(2);
00848       gPad->SetPad(0,0,1,0.4);
00849       c->cd(1);
00850       gPad->SetPad(0,0.4,1,1);
00851    }   
00852    if (gGeoManager) delete gGeoManager;
00853    new TGeoManager("parab", "paraboloid");
00854    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00855    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00856    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00857    gGeoManager->SetTopVolume(top);
00858    TGeoVolume *vol = gGeoManager->MakeParaboloid("PARAB",med,0, 40, 50); 
00859    TGeoParaboloid *par = (TGeoParaboloid*)vol->GetShape();
00860    vol->SetLineColor(randomColor());
00861    vol->SetLineWidth(2);
00862    top->AddNode(vol,1);
00863    gGeoManager->CloseGeometry();
00864    gGeoManager->SetNsegments(80);
00865    top->Draw();
00866    MakePicture();
00867    if (!comments) return;
00868    c->cd(2);
00869    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00870    pt->SetLineColor(1);
00871    TText *text = pt->AddText("TGeoParaboloid - Paraboloid class");
00872    text->SetTextColor(2);
00873    AddText(pt,"fRlo",par->GetRlo(),"radius at Z=-dz");
00874    AddText(pt,"fRhi",par->GetRhi(),"radius at Z=+dz");
00875    AddText(pt,"fDz",par->GetDz(),"half-length on Z axis");
00876    pt->AddText("----- A paraboloid is described by the equation:");
00877    pt->AddText("-----    z = a*r*r + b;   where: r = x*x + y*y");
00878    pt->AddText("----- Create with:    TGeoParaboloid *parab = new TGeoParaboloid(rlo, rhi, dz);");
00879    pt->AddText("-----    dz:  half-length in Z (range from -dz to +dz");
00880    pt->AddText("-----    rlo: radius at z=-dz given by: -dz = a*rlo*rlo + b");
00881    pt->AddText("-----    rhi: radius at z=+dz given by:  dz = a*rhi*rhi + b");
00882    pt->AddText("-----      rlo != rhi; both >= 0");
00883    pt->AddText(" ");
00884    pt->SetAllWith("-----","color",2);
00885    pt->SetAllWith("-----","font",72);
00886    pt->SetAllWith("-----","size",0.04);
00887    pt->SetTextAlign(12);
00888    pt->SetTextSize(0.044);
00889    pt->Draw();
00890    c->cd(1);
00891 }
00892 
00893 //______________________________________________________________________________
00894 void hype()
00895 {
00896    gROOT->GetListOfCanvases()->Delete();
00897    TCanvas *c = new TCanvas("hype shape", "A hyperboloid", 700,1000);
00898    if (comments) {
00899       c->Divide(1,2,0,0);
00900       c->cd(2);
00901       gPad->SetPad(0,0,1,0.4);
00902       c->cd(1);
00903       gPad->SetPad(0,0.4,1,1);
00904    }   
00905    if (gGeoManager) delete gGeoManager;
00906    new TGeoManager("hype", "hyperboloid");
00907    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00908    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00909    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00910    gGeoManager->SetTopVolume(top);
00911    TGeoVolume *vol = gGeoManager->MakeHype("HYPE",med,10, 45 ,20,45,40); 
00912    TGeoHype *hype = (TGeoHype*)vol->GetShape();
00913    vol->SetLineColor(randomColor());
00914    vol->SetLineWidth(2);
00915    top->AddNode(vol,1);
00916    gGeoManager->CloseGeometry();
00917    gGeoManager->SetNsegments(80);
00918    top->Draw();
00919    MakePicture();
00920    if (!comments) return;
00921    c->cd(2);
00922    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00923    pt->SetLineColor(1);
00924    TText *text = pt->AddText("TGeoHype - Hyperboloid class");
00925    text->SetTextColor(2);
00926    AddText(pt,"fRmin",hype->GetRmin(),"minimum inner radius");
00927    AddText(pt,"fStIn",hype->GetStIn(),"inner surface stereo angle [deg]");
00928    AddText(pt,"fRmax",hype->GetRmax(),"minimum outer radius");
00929    AddText(pt,"fStOut",hype->GetStOut(),"outer surface stereo angle [deg]");
00930    AddText(pt,"fDz",hype->GetDz(),"half-length on Z axis");
00931    pt->AddText("----- A hyperboloid is described by the equation:");
00932    pt->AddText("-----    r^2 - (tan(stereo)*z)^2 = rmin^2;   where: r = x*x + y*y");
00933    pt->AddText("----- Create with:    TGeoHype *hype = new TGeoHype(rin, stin, rout, stout, dz);");
00934    pt->AddText("-----      rin < rout; rout > 0");
00935    pt->AddText("-----      rin = 0; stin > 0 => inner surface conical");
00936    pt->AddText("-----      stin/stout = 0 => corresponding surface cyllindrical");
00937    pt->AddText(" ");
00938    pt->SetAllWith("-----","color",2);
00939    pt->SetAllWith("-----","font",72);
00940    pt->SetAllWith("-----","size",0.04);
00941    pt->SetTextAlign(12);
00942    pt->SetTextSize(0.044);
00943    pt->Draw();
00944    c->cd(1);
00945 }
00946 //______________________________________________________________________________
00947 void pcon(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
00948 {
00949    gROOT->GetListOfCanvases()->Delete();
00950    if (iaxis<0 || iaxis>3) {
00951       printf("Wrong division axis. Range is 1-3.\n");
00952       return;
00953    }   
00954    if (iaxis==1) {
00955       printf("Cannot divide pcon on Rxy\n");
00956       return;
00957    }   
00958    TCanvas *c = new TCanvas("pcon shape", "A polycone", 700,1000);
00959    if (comments) {
00960       c->Divide(1,2,0,0);
00961       c->cd(2);
00962       gPad->SetPad(0,0,1,0.4);
00963       c->cd(1);
00964       gPad->SetPad(0,0.4,1,1);
00965    }   
00966    if (gGeoManager) delete gGeoManager;
00967    new TGeoManager("pcon", "poza10");
00968    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
00969    TGeoMedium *med = new TGeoMedium("MED",1,mat);
00970    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
00971    gGeoManager->SetTopVolume(top);
00972    TGeoVolume *vol = gGeoManager->MakePcon("PCON",med, -30.0,300,4);
00973    TGeoPcon *pcon = (TGeoPcon*)(vol->GetShape());
00974    pcon->DefineSection(0,0,15,20);
00975    pcon->DefineSection(1,20,15,20);
00976    pcon->DefineSection(2,20,15,25);
00977    pcon->DefineSection(3,50,15,20);
00978    vol->SetLineColor(randomColor());
00979    vol->SetLineWidth(2);
00980    top->AddNode(vol,1);
00981    if (iaxis) {
00982       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
00983       if (!slice) return;
00984       slice->SetLineColor(randomColor());
00985    }
00986    gGeoManager->CloseGeometry();
00987    gGeoManager->SetNsegments(80);
00988    top->Draw();
00989    MakePicture();
00990    if (!comments) return;
00991    c->cd(2);
00992    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
00993    pt->SetLineColor(1);
00994    TText *text = pt->AddText("TGeoPcon - pcon class");
00995    text->SetTextColor(2);
00996    AddText(pt,"fPhi1",pcon->GetPhi1(),"lower phi limit");
00997    AddText(pt,"fDphi",pcon->GetDphi(),"phi range");
00998    AddText(pt,"fNz",pcon->GetNz(),"number of z planes");
00999    for (Int_t j=0; j<pcon->GetNz(); j++) {
01000       char line[128];
01001       sprintf(line, "fZ[%i]=%5.2f  fRmin[%i]=%5.2f  fRmax[%i]=%5.2f", 
01002               j,pcon->GetZ()[j],j,pcon->GetRmin()[j],j,pcon->GetRmax()[j]);
01003       text = pt->AddText(line);
01004       text->SetTextColor(4);
01005       text->SetTextAlign(12);
01006    }   
01007    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
01008    pt->AddText("Execute: pcon(iaxis, ndiv, start, step) to divide this.");
01009    pt->AddText("----- IAXIS can be 2 or 3 (Phi, Z)");
01010    pt->AddText("----- NDIV must be a positive integer");
01011    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
01012    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
01013    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
01014    pt->AddText(" ");
01015    pt->SetAllWith("-----","color",2);
01016    pt->SetAllWith("-----","font",72);
01017    pt->SetAllWith("-----","size",0.04);
01018    pt->SetAllWith("Execute","color",4);
01019    pt->SetTextAlign(12);
01020    pt->SetTextSize(0.044);
01021    pt->Draw();
01022    c->cd(1);
01023 //   SavePicture("pcon",c,vol,iaxis,step);
01024 }
01025 
01026 //______________________________________________________________________________
01027 void pgon(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
01028 {
01029    gROOT->GetListOfCanvases()->Delete();
01030    if (iaxis<0 || iaxis>3) {
01031       printf("Wrong division axis. Range is 1-3.\n");
01032       return;
01033    }   
01034    if (iaxis==1) {
01035       printf("Cannot divide pgon on Rxy\n");
01036       return;
01037    }   
01038    TCanvas *c = new TCanvas("pgon shape", "A polygone", 700,1000);
01039    if (comments) {
01040       c->Divide(1,2,0,0);
01041       c->cd(2);
01042       gPad->SetPad(0,0,1,0.4);
01043       c->cd(1);
01044       gPad->SetPad(0,0.4,1,1);
01045    }   
01046    if (gGeoManager) delete gGeoManager;
01047    new TGeoManager("pgon", "poza11");
01048    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
01049    TGeoMedium *med = new TGeoMedium("MED",1,mat);
01050    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,150,150,100);
01051    gGeoManager->SetTopVolume(top);
01052    TGeoVolume *vol = gGeoManager->MakePgon("PGON",med, -45.0,270.0,4,4);
01053    TGeoPgon *pgon = (TGeoPgon*)(vol->GetShape());
01054    pgon->DefineSection(0,-70,45,50);
01055    pgon->DefineSection(1,0,35,40);
01056    pgon->DefineSection(2,0,30,35);
01057    pgon->DefineSection(3,70,90,100);
01058    vol->SetLineColor(randomColor());
01059    vol->SetLineWidth(2);
01060    top->AddNode(vol,1);
01061    if (iaxis) {
01062       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
01063       if (!slice) return;
01064       slice->SetLineColor(randomColor());
01065    }
01066    gGeoManager->CloseGeometry();
01067    gGeoManager->SetNsegments(80);
01068    top->Draw();
01069    MakePicture();
01070    if (!comments) return;
01071    c->cd(2);
01072    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
01073    pt->SetLineColor(1);
01074    TText *text = pt->AddText("TGeoPgon - pgon class");
01075    text->SetTextColor(2);
01076    AddText(pt,"fPhi1",pgon->GetPhi1(),"lower phi limit");
01077    AddText(pt,"fDphi",pgon->GetDphi(),"phi range");
01078    AddText(pt,"fNedges",pgon->GetNedges(),"number of edges");
01079     AddText(pt,"fNz",pgon->GetNz(),"number of z planes");
01080    for (Int_t j=0; j<pgon->GetNz(); j++) {
01081       char line[128];
01082       sprintf(line, "fZ[%i]=%5.2f  fRmin[%i]=%5.2f  fRmax[%i]=%5.2f", 
01083               j,pgon->GetZ()[j],j,pgon->GetRmin()[j],j,pgon->GetRmax()[j]);
01084       text = pt->AddText(line);
01085       text->SetTextColor(4);
01086       text->SetTextAlign(12);
01087    }   
01088    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
01089    pt->AddText("Execute: pgon(iaxis, ndiv, start, step) to divide this.");
01090    pt->AddText("----- IAXIS can be 2 or 3 (Phi, Z)");
01091    pt->AddText("----- NDIV must be a positive integer");
01092    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
01093    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
01094    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
01095    pt->AddText(" ");
01096    pt->SetAllWith("-----","color",2);
01097    pt->SetAllWith("-----","font",72);
01098    pt->SetAllWith("-----","size",0.04);
01099    pt->SetAllWith("Execute","color",4);
01100    pt->SetTextAlign(12);
01101    pt->SetTextSize(0.044);
01102    pt->SetTextSize(0.044);
01103    pt->Draw();
01104    c->cd(1);
01105 //   SavePicture("pgon",c,vol,iaxis,step);
01106 }
01107 
01108 //______________________________________________________________________________
01109 void arb8(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
01110 {
01111    gROOT->GetListOfCanvases()->Delete();
01112    if (iaxis!=0) {
01113       printf("Cannot divide arb8\n");
01114       return;
01115    }   
01116    TCanvas *c = new TCanvas("arb8 shape", "An arbitrary polyedron", 700,1000);
01117    if (comments) {
01118       c->Divide(1,2,0,0);
01119       c->cd(2);
01120       gPad->SetPad(0,0,1,0.4);
01121       c->cd(1);
01122       gPad->SetPad(0,0.4,1,1);
01123    }   
01124    if (gGeoManager) delete gGeoManager;
01125    new TGeoManager("arb8", "poza12");
01126    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
01127    TGeoMedium *med = new TGeoMedium("MED",1,mat);
01128    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
01129    gGeoManager->SetTopVolume(top);
01130    TGeoArb8 *arb = new TGeoArb8(20);
01131    arb->SetVertex(0,-30,-25);
01132    arb->SetVertex(1,-25,25);
01133    arb->SetVertex(2,5,25);
01134    arb->SetVertex(3,25,-25);
01135    arb->SetVertex(4,-28,-23);
01136    arb->SetVertex(5,-23,27);
01137    arb->SetVertex(6,-23,27);
01138    arb->SetVertex(7,13,-27);
01139    TGeoVolume *vol = new TGeoVolume("ARB8",arb,med);
01140    vol->SetLineColor(randomColor());
01141    vol->SetLineWidth(2);
01142    top->AddNode(vol,1);
01143    if (iaxis) {
01144       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
01145       if (!slice) return;
01146       slice->SetLineColor(randomColor());
01147    }
01148    gGeoManager->CloseGeometry();
01149    gGeoManager->SetNsegments(80);
01150    top->Draw();
01151    MakePicture();
01152    if (!comments) return;
01153    c->cd(2);
01154    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
01155    pt->SetLineColor(1);
01156    TText *text = pt->AddText("TGeoArb8 - arb8 class");
01157    text->SetTextColor(2);
01158    AddText(pt,"fDz",arb->GetDz(),"Z half length");
01159    char line[128];
01160    Double_t *vert = arb->GetVertices();
01161    text = pt->AddText("Vertices on lower Z plane:");
01162    text->SetTextColor(3);
01163    Int_t i;
01164    for (i=0; i<4; i++) {
01165       sprintf(line,"   fXY[%d] = (%5.2f, %5.2f)", i, vert[2*i], vert[2*i+1]);
01166       text = pt->AddText(line);
01167       text->SetTextSize(0.043);
01168       text->SetTextColor(4);
01169    }      
01170    text = pt->AddText("Vertices on higher Z plane:");
01171    text->SetTextColor(3);
01172    for (i=4; i<8; i++) {
01173       sprintf(line,"   fXY[%d] = (%5.2f, %5.2f)", i, vert[2*i], vert[2*i+1]);
01174       text = pt->AddText(line);
01175       text->SetTextSize(0.043);
01176       text->SetTextColor(4);
01177    }      
01178       
01179    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
01180    pt->AddText(" ");
01181    pt->SetTextSize(0.043);
01182    pt->Draw();
01183    c->cd(1);
01184 //   SavePicture("arb8",c,vol,iaxis,step);
01185 }
01186 
01187 //______________________________________________________________________________
01188 void trd2(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
01189 {
01190    gROOT->GetListOfCanvases()->Delete();
01191    if (iaxis && iaxis!=3) {
01192       printf("Wrong division axis. Can divide only in Z (3)\n");
01193       return;
01194    }   
01195    TCanvas *c = new TCanvas("trd2 shape", "A trapezoid with dX and dY varying with Z", 700,1000);
01196    if (comments) {
01197       c->Divide(1,2,0,0);
01198       c->cd(2);
01199       gPad->SetPad(0,0,1,0.4);
01200       c->cd(1);
01201       gPad->SetPad(0,0.4,1,1);
01202    }   
01203    if (gGeoManager) delete gGeoManager;
01204    new TGeoManager("trd2", "poza9");
01205    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
01206    TGeoMedium *med = new TGeoMedium("MED",1,mat);
01207    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
01208    gGeoManager->SetTopVolume(top);
01209    TGeoVolume *vol = gGeoManager->MakeTrd2("Trd2",med, 10,20,30,10,40);
01210    vol->SetLineColor(randomColor());
01211    vol->SetLineWidth(2);
01212    top->AddNode(vol,1);
01213    if (iaxis) {
01214       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
01215       if (!slice) return;
01216       slice->SetLineColor(randomColor());
01217    }
01218    gGeoManager->CloseGeometry();
01219    gGeoManager->SetNsegments(80);
01220    top->Draw();
01221    MakePicture();
01222    if (!comments) return;
01223    c->cd(2);
01224    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
01225    pt->SetLineColor(1);
01226    TGeoTrd2 *trd2 = (TGeoTrd2*)(vol->GetShape());
01227    TText *text = pt->AddText("TGeoTrd2 - Trd2 class");
01228    text->SetTextColor(2);
01229    AddText(pt,"fDx1",trd2->GetDx1(),"half length in X at lower Z surface(-dz)");
01230    AddText(pt,"fDx2",trd2->GetDx2(),"half length in X at higher Z surface(+dz)");
01231    AddText(pt,"fDy1",trd2->GetDy1(),"half length in Y at lower Z surface(-dz)");
01232    AddText(pt,"fDy2",trd2->GetDy2(),"half length in Y at higher Z surface(-dz)");
01233    AddText(pt,"fDz",trd2->GetDz(),"half length in Z");
01234    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
01235    pt->AddText("Execute: trd2(iaxis, ndiv, start, step) to divide this.");
01236    pt->AddText("----- IAXIS can be only 3 (Z)");
01237    pt->AddText("----- NDIV must be a positive integer");
01238    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
01239    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
01240    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
01241    pt->AddText(" ");
01242    pt->SetAllWith("-----","color",2);
01243    pt->SetAllWith("-----","font",72);
01244    pt->SetAllWith("-----","size",0.04);
01245    pt->SetAllWith("Execute","color",4);
01246    pt->SetTextAlign(12);
01247    pt->SetTextSize(0.044);
01248    pt->Draw();
01249    c->cd(1);
01250 //   SavePicture("trd2",c,vol,iaxis,step);
01251 }
01252 
01253 //______________________________________________________________________________
01254 void trap(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
01255 {
01256    gROOT->GetListOfCanvases()->Delete();
01257    if (iaxis && iaxis!=3) {
01258       printf("Wrong division axis. Can divide only in Z (3)\n");
01259       return;
01260    }   
01261    TCanvas *c = new TCanvas("trap shape", "A more general trapezoid", 700,1000);
01262    if (comments) {
01263       c->Divide(1,2,0,0);
01264       c->cd(2);
01265       gPad->SetPad(0,0,1,0.4);
01266       c->cd(1);
01267       gPad->SetPad(0,0.4,1,1);
01268    }   
01269    if (gGeoManager) delete gGeoManager;
01270    new TGeoManager("trap", "poza10");
01271    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
01272    TGeoMedium *med = new TGeoMedium("MED",1,mat);
01273    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
01274    gGeoManager->SetTopVolume(top);
01275    TGeoVolume *vol = gGeoManager->MakeTrap("Trap",med, 30,15,30,20,10,15,0,20,10,15,0);
01276    vol->SetLineColor(randomColor());
01277    vol->SetLineWidth(2);
01278    top->AddNode(vol,1);
01279    if (iaxis) {
01280       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
01281       if (!slice) return;
01282       slice->SetLineColor(randomColor());
01283    }
01284    gGeoManager->CloseGeometry();
01285    gGeoManager->SetNsegments(80);
01286    top->Draw();
01287    MakePicture();
01288    if (!comments) return;
01289    c->cd(2);
01290    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
01291    pt->SetLineColor(1);
01292    TGeoTrap *trap = (TGeoTrap*)(vol->GetShape());
01293    TText *text = pt->AddText("TGeoTrap - Trapezoid class");
01294    text->SetTextColor(2);
01295    AddText(pt,"fDz",trap->GetDz(),"half length in Z");
01296    AddText(pt,"fTheta",trap->GetTheta(),"theta angle of trapezoid axis");
01297    AddText(pt,"fPhi",trap->GetPhi(),"phi angle of trapezoid axis");
01298    AddText(pt,"fH1",trap->GetH1(),"half length in y at -fDz");
01299    AddText(pt,"fAlpha1",trap->GetAlpha1(),"angle between centers of x edges and y axis at -fDz");
01300    AddText(pt,"fBl1",trap->GetBl1(),"half length in x at -dZ and y=-fH1");
01301    AddText(pt,"fTl1",trap->GetTl1(),"half length in x at -dZ and y=+fH1");
01302    AddText(pt,"fH2",trap->GetH2(),"half length in y at +fDz");
01303    AddText(pt,"fBl2",trap->GetBl2(),"half length in x at +dZ and y=-fH1");
01304    AddText(pt,"fTl2",trap->GetTl2(),"half length in x at +dZ and y=+fH1");
01305    AddText(pt,"fAlpha2",trap->GetAlpha2(),"angle between centers of x edges and y axis at +fDz");
01306    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
01307    pt->AddText("Execute: trap(iaxis, ndiv, start, step) to divide this.");
01308    pt->AddText("----- IAXIS can be only 3 (Z)");
01309    pt->AddText("----- NDIV must be a positive integer");
01310    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
01311    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
01312    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
01313    pt->AddText(" ");
01314    pt->SetAllWith("-----","color",2);
01315    pt->SetAllWith("-----","font",72);
01316    pt->SetAllWith("-----","size",0.04);
01317    pt->SetAllWith("Execute","color",4);
01318    pt->SetTextAlign(12);
01319    pt->SetTextSize(0.044);
01320    pt->Draw();
01321    c->cd(1);
01322 //   SavePicture("trap",c,vol,iaxis,step);
01323 }
01324 
01325 //______________________________________________________________________________
01326 void gtra(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
01327 {
01328    gROOT->GetListOfCanvases()->Delete();
01329    if (iaxis && iaxis!=3) {
01330       printf("Wrong division axis. Can divide only in Z (3)\n");
01331       return;
01332    }   
01333    TCanvas *c = new TCanvas("gtra shape", "A twisted trapezoid", 700,1000);
01334    if (comments) {
01335       c->Divide(1,2,0,0);
01336       c->cd(2);
01337       gPad->SetPad(0,0,1,0.4);
01338       c->cd(1);
01339       gPad->SetPad(0,0.4,1,1);
01340    }   
01341    if (gGeoManager) delete gGeoManager;
01342    new TGeoManager("gtra", "poza11");
01343    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
01344    TGeoMedium *med = new TGeoMedium("MED",1,mat);
01345    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
01346    gGeoManager->SetTopVolume(top);
01347    TGeoVolume *vol = gGeoManager->MakeGtra("Gtra",med, 30,15,30,30,20,10,15,0,20,10,15,0);
01348    vol->SetLineColor(randomColor());
01349    vol->SetLineWidth(2);
01350    top->AddNode(vol,1);
01351    if (iaxis) {
01352       TGeoVolume *slice = vol->Divide("SLICE",iaxis,ndiv,start,step);
01353       if (!slice) return;
01354       slice->SetLineColor(randomColor());
01355    }
01356    gGeoManager->CloseGeometry();
01357    gGeoManager->SetNsegments(80);
01358    top->Draw();
01359    MakePicture();
01360    if (!comments) return;
01361    c->cd(2);
01362    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
01363    pt->SetLineColor(1);
01364    TGeoGtra *trap = (TGeoGtra*)(vol->GetShape());
01365    TText *text = pt->AddText("TGeoGtra - Twisted trapezoid class");
01366    text->SetTextColor(2);
01367    AddText(pt,"fDz",trap->GetDz(),"half length in Z");
01368    AddText(pt,"fTheta",trap->GetTheta(),"theta angle of trapezoid axis");
01369    AddText(pt,"fPhi",trap->GetPhi(),"phi angle of trapezoid axis");
01370    AddText(pt,"fTwist",trap->GetTwistAngle(), "twist angle");
01371    AddText(pt,"fH1",trap->GetH1(),"half length in y at -fDz");
01372    AddText(pt,"fAlpha1",trap->GetAlpha1(),"angle between centers of x edges and y axis at -fDz");
01373    AddText(pt,"fBl1",trap->GetBl1(),"half length in x at -dZ and y=-fH1");
01374    AddText(pt,"fTl1",trap->GetTl1(),"half length in x at -dZ and y=+fH1");
01375    AddText(pt,"fH2",trap->GetH2(),"half length in y at +fDz");
01376    AddText(pt,"fBl2",trap->GetBl2(),"half length in x at +dZ and y=-fH1");
01377    AddText(pt,"fTl2",trap->GetTl2(),"half length in x at +dZ and y=+fH1");
01378    AddText(pt,"fAlpha2",trap->GetAlpha2(),"angle between centers of x edges and y axis at +fDz");
01379    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
01380    pt->AddText("Execute: gtra(iaxis, ndiv, start, step) to divide this.");
01381    pt->AddText("----- IAXIS can be only 3 (Z)");
01382    pt->AddText("----- NDIV must be a positive integer");
01383    pt->AddText("----- START must be a valid axis offset within shape range on divided axis");
01384    pt->AddText("----- STEP is the division step. START+NDIV*STEP must be in range also");
01385    pt->AddText("----- If START and STEP are omitted, all range of the axis will be divided");
01386    pt->AddText(" ");
01387    pt->SetAllWith("-----","color",2);
01388    pt->SetAllWith("-----","font",72);
01389    pt->SetAllWith("-----","size",0.04);
01390    pt->SetAllWith("Execute","color",4);
01391    pt->SetTextAlign(12);
01392    pt->SetTextSize(0.044);
01393    pt->Draw();
01394    c->cd(1);
01395 //   SavePicture("gtra",c,vol,iaxis,step);
01396 }
01397 
01398 //______________________________________________________________________________
01399 void xtru()
01400 {
01401    gROOT->GetListOfCanvases()->Delete();
01402    TCanvas *c = new TCanvas("gtra shape", "A twisted trapezoid", 700,1000);
01403    if (comments) {
01404       c->Divide(1,2,0,0);
01405       c->cd(2);
01406       gPad->SetPad(0,0,1,0.4);
01407       c->cd(1);
01408       gPad->SetPad(0,0.4,1,1);
01409    }   
01410    if (gGeoManager) delete gGeoManager;
01411    new TGeoManager("xtru", "poza12");
01412    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
01413    TGeoMedium *med = new TGeoMedium("MED",1,mat);
01414    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
01415    gGeoManager->SetTopVolume(top);
01416    TGeoVolume *vol = gGeoManager->MakeXtru("XTRU",med,4); 
01417    TGeoXtru *xtru = (TGeoXtru*)vol->GetShape();
01418    Double_t x[8] = {-30,-30,30,30,15,15,-15,-15};
01419    Double_t y[8] = {-30,30,30,-30,-30,15,15,-30};
01420    xtru->DefinePolygon(8,x,y);
01421    xtru->DefineSection(0,-40, -20., 10., 1.5);
01422    xtru->DefineSection(1, 10, 0., 0., 0.5);
01423    xtru->DefineSection(2, 10, 0., 0., 0.7);
01424    xtru->DefineSection(3, 40, 10., 20., 0.9);
01425    vol->SetLineColor(randomColor());
01426    vol->SetLineWidth(2);
01427    top->AddNode(vol,1);
01428    gGeoManager->CloseGeometry();
01429    gGeoManager->SetNsegments(80);
01430    top->Draw();
01431    MakePicture();
01432    if (!comments) return;
01433    c->cd(2);
01434    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
01435    pt->SetLineColor(1);
01436    TText *text = pt->AddText("TGeoXtru - Polygonal extrusion class");
01437    text->SetTextColor(2);
01438    AddText(pt,"fNvert",xtru->GetNvert(),"number of polygone vertices");
01439    AddText(pt,"fNz",xtru->GetNz(),"number of Z sections");
01440    pt->AddText("----- Any Z section is an arbitrary polygone");
01441    pt->AddText("----- The shape can have an arbitrary number of Z sections, as for pcon/pgon");
01442    pt->AddText("----- Create with:    TGeoXtru *xtru = new TGeoXtru(nz);");
01443    pt->AddText("----- Define the blueprint polygon :");
01444    pt->AddText("-----                 Double_t x[8] = {-30,-30,30,30,15,15,-15,-15};");
01445    pt->AddText("-----                 Double_t y[8] = {-30,30,30,-30,-30,15,15,-30};");
01446    pt->AddText("-----                 xtru->DefinePolygon(8,x,y);");
01447    pt->AddText("----- Define translations/scales of the blueprint for Z sections :");
01448    pt->AddText("-----                 xtru->DefineSection(i, Zsection, x0, y0, scale);");
01449    pt->AddText("----- Sections have to be defined in increasing Z order");
01450    pt->AddText("----- 2 sections can be defined at same Z (not for first/last sections)");
01451    pt->AddText(" ");
01452    pt->SetAllWith("-----","color",2);
01453    pt->SetAllWith("-----","font",72);
01454    pt->SetAllWith("-----","size",0.04);
01455    pt->SetTextAlign(12);
01456    pt->SetTextSize(0.044);
01457    pt->Draw();
01458    c->cd(1);
01459 }
01460 
01461 //______________________________________________________________________________
01462 void composite()
01463 {
01464    gROOT->GetListOfCanvases()->Delete();
01465    TCanvas *c = new TCanvas("composite shape", "A Boolean shape composition", 700,1000);
01466    if (comments) {
01467       c->Divide(1,2,0,0);
01468       c->cd(2);
01469       gPad->SetPad(0,0,1,0.4);
01470       c->cd(1);
01471       gPad->SetPad(0,0.4,1,1);
01472    }   
01473    if (gGeoManager) delete gGeoManager;
01474    new TGeoManager("xtru", "poza12");
01475    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
01476    TGeoMedium *med = new TGeoMedium("MED",1,mat);
01477    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,100);
01478    gGeoManager->SetTopVolume(top);
01479 
01480    // define shape components with names
01481    TGeoPgon *pgon = new TGeoPgon("pg",0.,360.,6,2); 
01482    pgon->DefineSection(0,0,0,20);
01483    pgon->DefineSection(1, 30,0,20);
01484 
01485    TGeoSphere *sph = new TGeoSphere("sph", 40., 45.);
01486    // define named geometrical transformations with names
01487    TGeoTranslation *tr = new TGeoTranslation(0., 0., 45.);
01488    tr->SetName("tr");
01489    // register all used transformations
01490    tr->RegisterYourself();
01491    // create the composite shape based on a Boolean expression
01492    TGeoCompositeShape *cs = new TGeoCompositeShape("mir", "sph:tr*pg");
01493 
01494    TGeoVolume *vol = new TGeoVolume("COMP",cs);
01495    vol->SetLineColor(randomColor());
01496    top->AddNode(vol,1);
01497    gGeoManager->CloseGeometry();
01498    gGeoManager->SetNsegments(100);
01499    top->Draw();
01500    MakePicture();
01501    if (!comments) return;
01502    c->cd(2);
01503    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
01504    pt->SetLineColor(1);
01505    TText *text = pt->AddText("TGeoCompositeShape - composite shape class");
01506    text->SetTextColor(2);
01507    pt->AddText("----- Define the shape components and don't forget to name them");
01508    pt->AddText("----- Define geometrical transformations that apply to shape components");
01509    pt->AddText("----- Name all transformations and register them");
01510    pt->AddText("----- Define the composite shape based on a Boolean expression");
01511    pt->AddText("                TGeoCompositeShape(\"someName\", \"expression\")");
01512    pt->AddText("----- Expression is made of <shapeName:transfName> components related by Boolean operators");
01513    pt->AddText("----- Boolean operators can be: (+) union, (-) subtraction and (*) intersection");
01514    pt->AddText("----- Use paranthesys in the expression to force precedence");   
01515    pt->AddText(" ");
01516    pt->SetAllWith("-----","color",4);
01517    pt->SetAllWith("-----","font",72);
01518    pt->SetAllWith("-----","size",0.04);
01519    pt->SetTextAlign(12);
01520    pt->SetTextSize(0.044);
01521    pt->Draw();
01522    c->cd(1);
01523 }
01524 
01525 //______________________________________________________________________________
01526 void ideal()
01527 {
01528 // This is an ideal geometry. In real life, some geometry pieces are moved/rotated
01529 // with respect to their ideal positions. This is called alignment. Alignment
01530 // operations can be handled by TGeo starting from a CLOSED geometry (applied a posteriori)
01531 // Alignment is handled by PHYSICAL NODES, representing an unique object in geometry.
01532 //
01533 // Creating physical nodes:
01534 // 1. TGeoPhysicalNode *node = gGeoManager->MakePhysicalNode(const char *path)
01535 //   - creates a physical node represented by path
01536 //   - path can be : TOP_1/A_2/B_3
01537 //   - B_3 is the 'final node' e.g. the logical node represented by this physical node
01538 // 2. TGeoPhysicalNode *node = gGeoManager->MakePhysicalNode()
01539 //   - creates a physical node representing the current modeller state
01540 
01541 // Setting visualisation options for TGeoPhysicalNode *node:
01542 // 1.   node->SetVisibility(Bool_t flag); // set node visible(*) or invisible
01543 // 2.   node->SetIsVolAtt(Bool_t flag);   // set line attributes to match the ones of the volumes in the branch
01544 //    - default - TRUE 
01545 //    - when called with FALSE - the attributes defined for the physical node will be taken
01546 //       node->SetLineColor(color);
01547 //       node->SetLineWidth(width);
01548 //       node->SetLineStyle(style);
01549 // 3.   node->SetVisibleFull(Bool_t flag); // not only last node in the branch is visible (default) 
01550 //
01551 // Activating/desactivating physical nodes drawing - not needed in case of alignment
01552 
01553 // Aligning physical nodes
01554 //==========================
01555 //      node->Align(TGeoMatrix *newmat, TGeoShape *newshape, Bool_t check=kFALSE);
01556 //   newmat = new matrix to replace final node LOCAL matrix
01557 //   newshape = new shape to replace final node shape
01558 //   check = optional check if the new aligned node is overlapping
01559 // gGeoManager->SetDrawExtraPaths(Bool_t flag)
01560    gROOT->GetListOfCanvases()->Delete();
01561    TCanvas *c = new TCanvas("composite shape", "A Boolean shape composition", 700,1000);
01562    if (comments) {
01563       c->Divide(1,2,0,0);
01564       c->cd(2);
01565       gPad->SetPad(0,0,1,0.4);
01566       c->cd(1);
01567       gPad->SetPad(0,0.4,1,1);
01568    }   
01569    gSystem->Load("libGeom");
01570    if (gGeoManager) delete gGeoManager;
01571    new TGeoManager("alignment", "Ideal geometry");
01572    TGeoMaterial *mat = new TGeoMaterial("Al", 26.98,13,2.7);
01573    TGeoMedium *med = new TGeoMedium("MED",1,mat);
01574    TGeoVolume *top = gGeoManager->MakeBox("TOP",med,100,100,10);
01575    gGeoManager->SetTopVolume(top);
01576    TGeoVolume *slicex = top->Divide("SX",1,10,-100,10);
01577    TGeoVolume *slicey = slicex->Divide("SY",2,10,-100,10);
01578    TGeoVolume *vol = gGeoManager->MakePgon("CELL",med,0.,360.,6,2);
01579    TGeoPgon *pgon = (TGeoPgon*)(vol->GetShape());
01580    pgon->DefineSection(0,-5,0.,2.);
01581    pgon->DefineSection(1,5,0.,2.);
01582    vol->SetLineColor(randomColor());
01583    slicey->AddNode(vol,1);
01584    gGeoManager->CloseGeometry();
01585    gGeoManager->SetNsegments(80);
01586    top->Draw();
01587    MakePicture();
01588    if (!comments) return;
01589    c->cd(2);
01590    TPaveText *pt = new TPaveText(0.01,0.01,0.99,0.99);
01591    pt->SetLineColor(1);
01592    TText *text = pt->AddText("Ideal / Aligned geometry");
01593    text->SetTextColor(2);
01594    pt->AddText("-- Create physical nodes for the objects you want to align");
01595    pt->AddText("-- You must start from a valid CLOSED geometry");
01596    pt->AddText("    TGeoPhysicalNode *node = gGeoManager->MakePhysicalNode(const char *path)");
01597    pt->AddText("    + creates a physical node represented by path, e.g. TOP_1/A_2/B_3");
01598    pt->AddText("    node->Align(TGeoMatrix *newmat, TGeoShape *newshape, Bool_t check=kFALSE)");
01599    pt->AddText("    + newmat = new matrix to replace final node LOCAL matrix");
01600    pt->AddText("    + newshape = new shape to replace final node shape");
01601    pt->AddText("    + check = optional check if the new aligned node is overlapping");
01602    pt->AddText(" ");
01603    pt->SetAllWith("--","color",4);
01604    pt->SetAllWith("--","font",72);
01605    pt->SetAllWith("--","size",0.04);
01606    pt->SetAllWith("+","color",2);
01607    pt->SetAllWith("+","font",72);
01608    pt->SetAllWith("+","size",0.04);
01609    pt->SetTextAlign(12);
01610    pt->SetTextSize(0.044);
01611    pt->Draw();
01612    c->cd(1);
01613 }
01614 
01615 //______________________________________________________________________________
01616 void align()
01617 {
01618    if (!gGeoManager) return;
01619    if (strcmp(gGeoManager->GetName(),"alignment")) {
01620       printf("Click: <Ideal geometry> first\n");
01621       return;
01622    }   
01623    char name[30];
01624    TObjArray *list = gGeoManager->GetListOfPhysicalNodes();
01625    TGeoPhysicalNode *node;
01626    TGeoTranslation *tr;
01627    for (Int_t i=1; i<=10; i++) {
01628       for (Int_t j=1; j<=10; j++) {
01629          node = 0;
01630          sprintf(name, "TOP_1/SX_%d/SY_%d/CELL_1",i,j);
01631          if (list) node = (TGeoPhysicalNode*)list->At(10*(i-1)+j-1);         
01632          if (!node) node = gGeoManager->MakePhysicalNode(name);
01633          if (node->IsAligned()) {
01634             tr = (TGeoTranslation*)node->GetNode()->GetMatrix();
01635             tr->SetTranslation(2.*gRandom->Rndm(), 2.*gRandom->Rndm(),0.);
01636          } else {  
01637             tr = new TGeoTranslation(2.*gRandom->Rndm(), 2.*gRandom->Rndm(),0.);
01638          }   
01639          node->Align(tr);
01640       }
01641    }
01642    if (gPad) {
01643       gPad->Modified();
01644       gPad->Update();
01645    }   
01646 }
01647 
01648 //______________________________________________________________________________
01649 void MakePicture()
01650 {
01651    TView *view = gPad->GetView();
01652    if (view) {
01653 //      view->RotateView(248,66);
01654       if (axis) view->ShowAxis();
01655    }
01656    Bool_t is_raytracing = gGeoManager->GetGeomPainter()->IsRaytracing();
01657    if (is_raytracing != raytracing) {
01658       gGeoManager->GetGeomPainter()->SetRaytracing(raytracing);
01659       gPad->Modified();
01660       gPad->Update();
01661    }   
01662 }
01663       
01664 //______________________________________________________________________________
01665 void AddText(TPaveText *pave, const char *datamember, Double_t value, const char *comment)
01666 {
01667    char line[128];
01668    for (Int_t i=0; i<128; i++) line[i] = ' ';
01669    memcpy(&line[0], datamember, strlen(datamember));
01670    line[10] = '=';
01671    char number[20];
01672    sprintf(number, "%5.2f", value);
01673    memcpy(&line[12], number, strlen(number));
01674    line[26] = '=';
01675    line[27] = '>';
01676    sprintf(&line[30], "%s",comment);
01677    TText *text = pave->AddText(line);
01678 //   text->SetTextColor(4);
01679    text->SetTextAlign(12);//12
01680 }
01681 
01682 //______________________________________________________________________________
01683 void AddText(TPaveText *pave, const char *datamember, Int_t value, const char *comment)
01684 {
01685    char line[128];
01686    for (Int_t i=0; i<128; i++) line[i] = ' ';
01687    memcpy(&line[0], datamember, strlen(datamember));
01688    line[10] = '=';
01689    char number[20];
01690    sprintf(number, "%5i", value);
01691    memcpy(&line[12], number, strlen(number));
01692    line[26] = '=';
01693    line[27] = '>';
01694    sprintf(&line[30], "%s",comment);
01695    TText *text = pave->AddText(line);
01696 //   text->SetTextColor(4);
01697    text->SetTextAlign(12);
01698 }
01699 
01700 //______________________________________________________________________________
01701 void AddText(TPaveText *pave, TObject *pf, Int_t iaxis)
01702 {
01703    char line[128];
01704    TGeoPatternFinder *finder = (TGeoPatternFinder*)pf;
01705    if (!pave || !pf) return;
01706    for (Int_t i=0; i<128; i++) line[i] = ' ';
01707    TGeoVolume *volume = finder->GetVolume();
01708    TGeoShape *sh = volume->GetShape();
01709    sprintf(line, "Division of %s on axis %d (%s)", volume->GetName(), iaxis,sh->GetAxisName(iaxis));
01710    TText *text = pave->AddText(line);
01711    text->SetTextColor(3);
01712    text->SetTextAlign(12);
01713    AddText(pave, "fNdiv",finder->GetNdiv(),"number of divisions");
01714    AddText(pave, "fStart",finder->GetStart(),"start divisioning position");
01715    AddText(pave, "fStep",finder->GetStep(),"division step");
01716 }
01717 
01718 //______________________________________________________________________________
01719 void SavePicture(const char *name, TObject *objcanvas, TObject *objvol, Double_t iaxis, Double_t step)
01720 {
01721    TCanvas *c = (TCanvas*)objcanvas;
01722    TGeoVolume *vol = (TGeoVolume*)objvol;
01723    if (!c || !vol) return;
01724    c->cd();
01725    char fname[32];
01726    switch (iaxis) {
01727       case 0:
01728          sprintf(fname,"t_%s.gif",name);
01729          break;
01730       default:
01731          if (step==0) sprintf(fname,"t_%sdiv%s.gif", name,vol->GetShape()->GetAxisName(iaxis));
01732          else sprintf(fname,"t_%sdivstep%s.gif", name,vol->GetShape()->GetAxisName(iaxis));
01733    }     
01734    c->Print(fname);
01735 }
01736 
01737 //______________________________________________________________________________
01738 Int_t randomColor()
01739 {
01740    Double_t color = 7.*gRandom->Rndm();
01741    return (1+Int_t(color));
01742 }   
01743 
01744 //______________________________________________________________________________
01745 void raytrace() {
01746    raytracing = !raytracing;
01747    if (!gGeoManager) return;
01748    TVirtualGeoPainter *painter = gGeoManager->GetGeomPainter();
01749    if (!painter) return;
01750    painter->SetRaytracing(raytracing);
01751    if (!gPad) return;
01752    gPad->Modified();
01753    gPad->Update();
01754 }
01755 
01756 //______________________________________________________________________________
01757 void help() {
01758    //
01759   
01760    new TCanvas("chelp","Help to run demos",200,10,700,600);
01761 
01762    welcome = new TPaveText(.1,.8,.9,.97);
01763    welcome->AddText("Welcome to the new geometry package");
01764    welcome->SetTextFont(32);
01765    welcome->SetTextColor(4);
01766    welcome->SetFillColor(24);
01767    welcome->Draw();
01768 
01769    hdemo = new TPaveText(.05,.05,.95,.7);
01770    hdemo->SetTextAlign(12);
01771    hdemo->SetTextFont(52);
01772    hdemo->AddText("- Demo for building TGeo basic shapes and simple geometry. Shape parameters are");
01773    hdemo->AddText("  displayed in the right pad");
01774    hdemo->AddText("- Click left mouse button to execute one demo");
01775    hdemo->AddText("- While pointing the mouse to the pad containing the geometry, do:");
01776    hdemo->AddText("- .... click-and-move to rotate");
01777    hdemo->AddText("- .... press j/k to zoom/unzoom");
01778    hdemo->AddText("- .... press l/h/u/i to move the view center arround");
01779    hdemo->AddText("- Click Ray-trace ON/OFF to toggle ray-tracing");
01780    hdemo->AddText("- Use <View with x3d> from the <View> menu to get an x3d view");
01781    hdemo->AddText("- .... same methods to rotate/zoom/move the view");
01782    hdemo->AddText("- Execute box(1,8) to divide a box in 8 equal slices along X");
01783    hdemo->AddText("- Most shapes can be divided on X,Y,Z,Rxy or Phi :");
01784    hdemo->AddText("- .... root[0] <shape>(IAXIS, NDIV, START, STEP);");
01785    hdemo->AddText("  .... IAXIS = 1,2,3 meaning (X,Y,Z) or (Rxy, Phi, Z)");
01786    hdemo->AddText("  .... NDIV  = number of slices");
01787    hdemo->AddText("  .... START = start slicing position");
01788    hdemo->AddText("  .... STEP  = division step");
01789    hdemo->AddText("- Click Comments ON/OFF to toggle comments");
01790    hdemo->AddText("- Click Ideal/Align geometry to see how alignment works");
01791    hdemo->AddText(" ");
01792    hdemo->SetAllWith("....","color",2);
01793    hdemo->SetAllWith("....","font",72);
01794    hdemo->SetAllWith("....","size",0.03);
01795 
01796    hdemo->Draw();
01797 }

Generated on Tue Jul 5 15:44:12 2011 for ROOT_528-00b_version by  doxygen 1.5.1