39 Bool_t comments = kTRUE;
 
   40 Bool_t raytracing = kFALSE;
 
   41 Bool_t grotate = kFALSE;
 
   47    TView *view = gPad->GetView();
 
   50       if (axis) view->ShowAxis();
 
   52    Bool_t is_raytracing = gGeoManager->GetGeomPainter()->IsRaytracing();
 
   53    if (is_raytracing != raytracing) {
 
   54       gGeoManager->GetGeomPainter()->SetRaytracing(raytracing);
 
   61 void AddText(TPaveText *pave, 
const char *datamember, Double_t value, 
const char *comment)
 
   64    for (Int_t i=0; i<128; i++) line[i] = 
' ';
 
   65    memcpy(&line[0], datamember, strlen(datamember));
 
   68    sprintf(number, 
"%5.2f", value);
 
   69    memcpy(&line[12], number, strlen(number));
 
   72    sprintf(&line[30], 
"%s",comment);
 
   73    TText *text = pave->AddText(line);
 
   75    text->SetTextAlign(12);
 
   79 void AddText(TPaveText *pave, 
const char *datamember, Int_t value, 
const char *comment)
 
   82    for (Int_t i=0; i<128; i++) line[i] = 
' ';
 
   83    memcpy(&line[0], datamember, strlen(datamember));
 
   86    sprintf(number, 
"%5i", value);
 
   87    memcpy(&line[12], number, strlen(number));
 
   90    sprintf(&line[30], 
"%s",comment);
 
   91    TText *text = pave->AddText(line);
 
   93    text->SetTextAlign(12);
 
   97 void AddText(TPaveText *pave, TObject *pf, Int_t iaxis)
 
  100    TGeoPatternFinder *finder = (TGeoPatternFinder*)pf;
 
  101    if (!pave || !pf) 
return;
 
  102    for (Int_t i=0; i<128; i++) line[i] = 
' ';
 
  103    TGeoVolume *volume = finder->GetVolume();
 
  104    TGeoShape *sh = volume->GetShape();
 
  105    sprintf(line, 
"Division of %s on axis %d (%s)", volume->GetName(), iaxis,sh->GetAxisName(iaxis));
 
  106    TText *text = pave->AddText(line);
 
  107    text->SetTextColor(3);
 
  108    text->SetTextAlign(12);
 
  109    AddText(pave, 
"fNdiv",finder->GetNdiv(),
"number of divisions");
 
  110    AddText(pave, 
"fStart",finder->GetStart(),
"start divisioning position");
 
  111    AddText(pave, 
"fStep",finder->GetStep(),
"division step");
 
  115 void SavePicture(
const char *name, TObject *objcanvas, TObject *objvol, Int_t iaxis, Double_t step)
 
  117    TCanvas *c = (TCanvas*)objcanvas;
 
  118    TGeoVolume *vol = (TGeoVolume*)objvol;
 
  119    if (!c || !vol) 
return;
 
  124          sprintf(fname,
"t_%s.gif",name);
 
  127          if (step==0) sprintf(fname,
"t_%sdiv%s.gif", name,vol->GetShape()->GetAxisName(iaxis));
 
  128          else sprintf(fname,
"t_%sdivstep%s.gif", name,vol->GetShape()->GetAxisName(iaxis));
 
  136    Double_t color = 7.*gRandom->Rndm();
 
  137    return (1+Int_t(color));
 
  142    raytracing = !raytracing;
 
  143    if (!gGeoManager) 
return;
 
  144    TVirtualGeoPainter *painter = gGeoManager->GetGeomPainter();
 
  145    if (!painter) 
return;
 
  146    painter->SetRaytracing(raytracing);
 
  156    new TCanvas(
"chelp",
"Help to run demos",200,10,700,600);
 
  158    TPaveText *welcome = 
new TPaveText(.1,.8,.9,.97);
 
  159    welcome->AddText(
"Welcome to the new geometry package");
 
  160    welcome->SetTextFont(32);
 
  161    welcome->SetTextColor(4);
 
  162    welcome->SetFillColor(24);
 
  165    TPaveText *hdemo = 
new TPaveText(.05,.05,.95,.7);
 
  166    hdemo->SetTextAlign(12);
 
  167    hdemo->SetTextFont(52);
 
  168    hdemo->AddText(
"- Demo for building TGeo basic shapes and simple geometry. Shape parameters are");
 
  169    hdemo->AddText(
"  displayed in the right pad");
 
  170    hdemo->AddText(
"- Click left mouse button to execute one demo");
 
  171    hdemo->AddText(
"- While pointing the mouse to the pad containing the geometry, do:");
 
  172    hdemo->AddText(
"- .... click-and-move to rotate");
 
  173    hdemo->AddText(
"- .... press j/k to zoom/unzoom");
 
  174    hdemo->AddText(
"- .... press l/h/u/i to move the view center around");
 
  175    hdemo->AddText(
"- Click Ray-trace ON/OFF to toggle ray-tracing");
 
  176    hdemo->AddText(
"- Use <View with x3d> from the <View> menu to get an x3d view");
 
  177    hdemo->AddText(
"- .... same methods to rotate/zoom/move the view");
 
  178    hdemo->AddText(
"- Execute box(1,8) to divide a box in 8 equal slices along X");
 
  179    hdemo->AddText(
"- Most shapes can be divided on X,Y,Z,Rxy or Phi :");
 
  180    hdemo->AddText(
"- .... root[0] <shape>(IAXIS, NDIV, START, STEP);");
 
  181    hdemo->AddText(
"  .... IAXIS = 1,2,3 meaning (X,Y,Z) or (Rxy, Phi, Z)");
 
  182    hdemo->AddText(
"  .... NDIV  = number of slices");
 
  183    hdemo->AddText(
"  .... START = start slicing position");
 
  184    hdemo->AddText(
"  .... STEP  = division step");
 
  185    hdemo->AddText(
"- Click Comments ON/OFF to toggle comments");
 
  186    hdemo->AddText(
"- Click Ideal/Align geometry to see how alignment works");
 
  188    hdemo->SetAllWith(
"....",
"color",2);
 
  189    hdemo->SetAllWith(
"....",
"font",72);
 
  190    hdemo->SetAllWith(
"....",
"size",0.03);
 
  213    TControlBar *bar = 
new TControlBar(
"vertical", 
"TGeo shapes",10,10);
 
  214    bar->AddButton(
"How to run  ",
"help()",
"Instructions for running this macro");
 
  215    bar->AddButton(
"Arb8        ",
"arb8()",
"An arbitrary polyhedron defined by vertices (max 8) sitting on 2 parallel planes");
 
  216    bar->AddButton(
"Box         ",
"box()",
"A box shape.");
 
  217    bar->AddButton(
"Composite   ",
"composite()",
"A composite shape");
 
  218    bar->AddButton(
"Cone        ",
"cone()",
"A conical tube");
 
  219    bar->AddButton(
"Cone segment",
"coneseg()",
"A conical segment");
 
  220    bar->AddButton(
"Cut tube    ",
"ctub()",
"A cut tube segment");
 
  221    bar->AddButton(
"Elliptical tube",
"eltu()",
"An elliptical tube");
 
  222    bar->AddButton(
"Extruded poly",
"xtru()",
"A general polygone extrusion");
 
  223    bar->AddButton(
"Hyperboloid  ",
"hype()",
"A hyperboloid");
 
  224    bar->AddButton(
"Paraboloid  ",
"parab()",
"A paraboloid");
 
  225    bar->AddButton(
"Polycone    ",
"pcon()",
"A polycone shape");
 
  226    bar->AddButton(
"Polygone    ",
"pgon()",
"A polygone");
 
  227    bar->AddButton(
"Parallelepiped",
"para()",
"A parallelepiped shape");
 
  228    bar->AddButton(
"Sphere      ",
"sphere()",
"A spherical sector");
 
  229    bar->AddButton(
"Trd1        ",
"trd1()",
"A trapezoid with dX varying with Z");
 
  230    bar->AddButton(
"Trd2        ",
"trd2()",
"A trapezoid with both dX and dY varying with Z");
 
  231    bar->AddButton(
"Trapezoid   ",
"trap()",
"A general trapezoid");
 
  232    bar->AddButton(
"Torus       ",
"torus()",
"A toroidal segment");
 
  233    bar->AddButton(
"Tube        ",
"tube()",
"A tube with inner and outer radius");
 
  234    bar->AddButton(
"Tube segment",
"tubeseg()",
"A tube segment");
 
  235    bar->AddButton(
"Twisted trap",
"gtra()",
"A twisted trapezoid");
 
  236    bar->AddButton(
"Aligned (ideal)",
"ideal()",
"An ideal (un-aligned) geometry");
 
  237    bar->AddButton(
"Un-aligned",
"align()",
"Some alignment operation");
 
  238    bar->AddButton(
"RAY-TRACE ON/OFF",
"raytrace()",
"Toggle ray-tracing mode");
 
  239    bar->AddButton(
"COMMENTS  ON/OFF",
"comments = !comments;",
"Toggle explanations pad ON/OFF");
 
  240    bar->AddButton(
"AXES ON/OFF",
"axes()",
"Toggle axes ON/OFF");
 
  241    bar->AddButton(
"AUTOROTATE ON/OFF",
"autorotate()",
"Toggle autorotation ON/OFF");
 
  243    gROOT->SaveContext();
 
  244    gRandom = 
new TRandom3();
 
  252       gROOT->SetInterrupt(kTRUE);
 
  256    TView *view = gPad->GetView();
 
  258    if (!gGeoManager) 
return;
 
  259    TVirtualGeoPainter *painter = gGeoManager->GetGeomPainter();
 
  260    if (!painter) 
return;
 
  261    Double_t longit = view->GetLongitude();
 
  266    TProcessEventTimer *timer = 
new TProcessEventTimer(5);
 
  267    gROOT->SetInterrupt(kFALSE);
 
  269       if (timer->ProcessEvents()) 
break;
 
  270       if (gROOT->IsInterrupted()) 
break;
 
  272       if (longit>360) longit -= 360.;
 
  277       view = gPad->GetView();
 
  282       view->SetView(longit,view->GetLatitude(),view->GetPsi(),irep);
 
  294    TView *view = gPad->GetView();
 
  299 void box(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  301    gROOT->GetListOfCanvases()->Delete();
 
  302    if (iaxis<0 || iaxis>3) {
 
  303       printf(
"Wrong division axis. Range is 1-3.\n");
 
  306    TCanvas *c = 
new TCanvas(
"box shape", 
"A simple box", 700,1000);
 
  310       gPad->SetPad(0,0,1,0.4);
 
  312       gPad->SetPad(0,0.4,1,1);
 
  314    if (gGeoManager) 
delete gGeoManager;
 
  315    new TGeoManager(
"box", 
"poza1");
 
  316    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  317    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  318    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  319    gGeoManager->SetTopVolume(top);
 
  320    TGeoVolume *vol = gGeoManager->MakeBox(
"BOX",med, 20,30,40);
 
  321    vol->SetLineColor(randomColor());
 
  322    vol->SetLineWidth(2);
 
  325       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  327       slice->SetLineColor(randomColor());
 
  329    gGeoManager->CloseGeometry();
 
  330    gGeoManager->SetNsegments(80);
 
  333    if (!comments) 
return;
 
  335    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  337    TGeoBBox *box = (TGeoBBox*)(vol->GetShape());
 
  338    TText *text = pt->AddText(
"TGeoBBox - box class");
 
  339    text->SetTextColor(2);
 
  340    AddText(pt,
"fDX",box->GetDX(),
"half length in X");
 
  341    AddText(pt,
"fDY",box->GetDY(),
"half length in Y");
 
  342    AddText(pt,
"fDZ",box->GetDZ(),
"half length in Z");
 
  343    AddText(pt,
"fOrigin[0]",(box->GetOrigin())[0],
"box origin on X");
 
  344    AddText(pt,
"fOrigin[1]",(box->GetOrigin())[1],
"box origin on Y");
 
  345    AddText(pt,
"fOrigin[2]",(box->GetOrigin())[2],
"box origin on Z");
 
  346    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  347    pt->AddText(
"Execute: box(iaxis, ndiv, start, step) to divide this.");
 
  348    pt->AddText(
"----- IAXIS can be 1, 2 or 3 (X, Y, Z)");
 
  349    pt->AddText(
"----- NDIV must be a positive integer");
 
  350    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
  351    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
  352    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
  354    pt->SetTextSize(0.044);
 
  355    pt->SetAllWith(
"-----",
"color",2);
 
  356    pt->SetAllWith(
"-----",
"font",72);
 
  357    pt->SetAllWith(
"-----",
"size",0.04);
 
  358    pt->SetAllWith(
"Execute",
"color",4);
 
  359    pt->SetTextAlign(12);
 
  363    gROOT->SetInterrupt(kTRUE);
 
  367 void para(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  369    gROOT->GetListOfCanvases()->Delete();
 
  370    TCanvas *c = 
new TCanvas(
"para shape", 
"A parallelepiped", 700,1000);
 
  374       gPad->SetPad(0,0,1,0.4);
 
  376       gPad->SetPad(0,0.4,1,1);
 
  378    if (gGeoManager) 
delete gGeoManager;
 
  379    new TGeoManager(
"para", 
"poza1");
 
  380    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  381    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  382    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  383    gGeoManager->SetTopVolume(top);
 
  384    TGeoVolume *vol = gGeoManager->MakePara(
"PARA",med, 20,30,40,30,15,30);
 
  385    vol->SetLineColor(randomColor());
 
  386    vol->SetLineWidth(2);
 
  389       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  391       slice->SetLineColor(randomColor());
 
  393    gGeoManager->CloseGeometry();
 
  394    gGeoManager->SetNsegments(80);
 
  397    if (!comments) 
return;
 
  399    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  401    TGeoPara *para = (TGeoPara*)(vol->GetShape());
 
  402    TText *text = pt->AddText(
"TGeoPara - parallelepiped class");
 
  403    text->SetTextColor(2);
 
  404    AddText(pt,
"fX",para->GetX(),
"half length in X");
 
  405    AddText(pt,
"fY",para->GetY(),
"half length in Y");
 
  406    AddText(pt,
"fZ",para->GetZ(),
"half length in Z");
 
  407    AddText(pt,
"fAlpha",para->GetAlpha(),
"angle about Y of the Z bases");
 
  408    AddText(pt,
"fTheta",para->GetTheta(),
"inclination of para axis about Z");
 
  409    AddText(pt,
"fPhi",para->GetPhi(),
"phi angle of para axis");
 
  410    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  411    pt->AddText(
"Execute: para(iaxis, ndiv, start, step) to divide this.");
 
  412    pt->AddText(
"----- IAXIS can be 1, 2 or 3 (X, Y, Z)");
 
  413    pt->AddText(
"----- NDIV must be a positive integer");
 
  414    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
  415    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
  416    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
  418    pt->SetTextSize(0.044);
 
  419    pt->SetAllWith(
"-----",
"color",2);
 
  420    pt->SetAllWith(
"-----",
"font",72);
 
  421    pt->SetAllWith(
"-----",
"size",0.04);
 
  422    pt->SetAllWith(
"Execute",
"color",4);
 
  423    pt->SetTextAlign(12);
 
  430 void tube(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  432    gROOT->GetListOfCanvases()->Delete();
 
  433    if (iaxis<0 || iaxis>3) {
 
  434       printf(
"Wrong division axis. Range is 1-3.\n");
 
  437    TCanvas *c = 
new TCanvas(
"tube shape", 
"A tube", 700,1000);
 
  441       gPad->SetPad(0,0,1,0.4);
 
  443       gPad->SetPad(0,0.4,1,1);
 
  445    if (gGeoManager) 
delete gGeoManager;
 
  446    new TGeoManager(
"tube", 
"poza2");
 
  447    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  448    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  449    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  450    gGeoManager->SetTopVolume(top);
 
  451    TGeoVolume *vol = gGeoManager->MakeTube(
"TUBE",med, 20,30,40);
 
  452    vol->SetLineColor(randomColor());
 
  453    vol->SetLineWidth(2);
 
  456       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  458       slice->SetLineColor(randomColor());
 
  460    gGeoManager->CloseGeometry();
 
  462    gGeoManager->SetNsegments(80);
 
  465    if (!comments) 
return;
 
  467    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  469    TGeoTube *tube = (TGeoTube*)(vol->GetShape());
 
  470    TText *text = pt->AddText(
"TGeoTube - tube class");
 
  471    text->SetTextColor(2);
 
  472    AddText(pt,
"fRmin",tube->GetRmin(),
"minimum radius");
 
  473    AddText(pt,
"fRmax",tube->GetRmax(),
"maximum radius");
 
  474    AddText(pt,
"fDZ",  tube->GetDZ(),  
"half length in Z");
 
  475    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  476    pt->AddText(
"Execute: tube(iaxis, ndiv, start, step) to divide this.");
 
  477    pt->AddText(
"----- IAXIS can be 1, 2 or 3 (Rxy, Phi, Z)");
 
  478    pt->AddText(
"----- NDIV must be a positive integer");
 
  479    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
  480    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
  481    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
  483    pt->SetAllWith(
"-----",
"color",2);
 
  484    pt->SetAllWith(
"-----",
"font",72);
 
  485    pt->SetAllWith(
"-----",
"size",0.04);
 
  486    pt->SetAllWith(
"Execute",
"color",4);
 
  487    pt->SetTextAlign(12);
 
  488    pt->SetTextSize(0.044);
 
  495 void tubeseg(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  497    gROOT->GetListOfCanvases()->Delete();
 
  498    if (iaxis<0 || iaxis>3) {
 
  499       printf(
"Wrong division axis. Range is 1-3.\n");
 
  502    TCanvas *c = 
new TCanvas(
"tubeseg shape", 
"A tube segment ", 700,1000);
 
  506       gPad->SetPad(0,0,1,0.4);
 
  508       gPad->SetPad(0,0.4,1,1);
 
  510    if (gGeoManager) 
delete gGeoManager;
 
  511    new TGeoManager(
"tubeseg", 
"poza3");
 
  512    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  513    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  514    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  515    gGeoManager->SetTopVolume(top);
 
  516    TGeoVolume *vol = gGeoManager->MakeTubs(
"TUBESEG",med, 20,30,40,-30,270);
 
  517    vol->SetLineColor(randomColor());
 
  519       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  521       slice->SetLineColor(randomColor());
 
  523    vol->SetLineWidth(2);
 
  525    gGeoManager->CloseGeometry();
 
  527    gGeoManager->SetNsegments(80);
 
  530    if (!comments) 
return;
 
  532    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  534    TGeoTubeSeg *tubeseg = (TGeoTubeSeg*)(vol->GetShape());
 
  535    TText *text = pt->AddText(
"TGeoTubeSeg - tube segment class");
 
  536    text->SetTextColor(2);
 
  537    AddText(pt,
"fRmin",tubeseg->GetRmin(),
"minimum radius");
 
  538    AddText(pt,
"fRmax",tubeseg->GetRmax(),
"maximum radius");
 
  539    AddText(pt,
"fDZ",  tubeseg->GetDZ(),  
"half length in Z");
 
  540    AddText(pt,
"fPhi1",tubeseg->GetPhi1(),
"first phi limit");
 
  541    AddText(pt,
"fPhi2",tubeseg->GetPhi2(),
"second phi limit");
 
  542    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  543    pt->AddText(
"Execute: tubeseg(iaxis, ndiv, start, step) to divide this.");
 
  544    pt->AddText(
"----- IAXIS can be 1, 2 or 3 (Rxy, Phi, Z)");
 
  545    pt->AddText(
"----- NDIV must be a positive integer");
 
  546    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
  547    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
  548    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
  550    pt->SetAllWith(
"-----",
"color",2);
 
  551    pt->SetAllWith(
"-----",
"font",72);
 
  552    pt->SetAllWith(
"-----",
"size",0.04);
 
  553    pt->SetAllWith(
"Execute",
"color",4);
 
  554    pt->SetTextAlign(12);
 
  555    pt->SetTextSize(0.044);
 
  562 void ctub(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  564    gROOT->GetListOfCanvases()->Delete();
 
  565    if (iaxis<0 || iaxis>2) {
 
  566       printf(
"Wrong division axis. Range is 1-2.\n");
 
  569    TCanvas *c = 
new TCanvas(
"ctub shape", 
"A cut tube segment ", 700,1000);
 
  573       gPad->SetPad(0,0,1,0.4);
 
  575       gPad->SetPad(0,0.4,1,1);
 
  577    if (gGeoManager) 
delete gGeoManager;
 
  578    new TGeoManager(
"ctub", 
"poza3");
 
  579    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  580    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  581    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  582    gGeoManager->SetTopVolume(top);
 
  583    Double_t theta = 160.*TMath::Pi()/180.;
 
  584    Double_t phi   = 30.*TMath::Pi()/180.;
 
  586    nlow[0] = TMath::Sin(theta)*TMath::Cos(phi);
 
  587    nlow[1] = TMath::Sin(theta)*TMath::Sin(phi);
 
  588    nlow[2] = TMath::Cos(theta);
 
  589    theta = 20.*TMath::Pi()/180.;
 
  590    phi   = 60.*TMath::Pi()/180.;
 
  592    nhi[0] = TMath::Sin(theta)*TMath::Cos(phi);
 
  593    nhi[1] = TMath::Sin(theta)*TMath::Sin(phi);
 
  594    nhi[2] = TMath::Cos(theta);
 
  595    TGeoVolume *vol = gGeoManager->MakeCtub(
"CTUB",med, 20,30,40,-30,250, nlow[0], nlow[1], nlow[2], nhi[0],nhi[1],nhi[2]);
 
  596    vol->SetLineColor(randomColor());
 
  598       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  600       slice->SetLineColor(randomColor());
 
  602    vol->SetLineWidth(2);
 
  604    gGeoManager->CloseGeometry();
 
  606    gGeoManager->SetNsegments(80);
 
  609    if (!comments) 
return;
 
  611    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  613    TGeoTubeSeg *tubeseg = (TGeoTubeSeg*)(vol->GetShape());
 
  614    TText *text = pt->AddText(
"TGeoTubeSeg - tube segment class");
 
  615    text->SetTextColor(2);
 
  616    AddText(pt,
"fRmin",tubeseg->GetRmin(),
"minimum radius");
 
  617    AddText(pt,
"fRmax",tubeseg->GetRmax(),
"maximum radius");
 
  618    AddText(pt,
"fDZ",  tubeseg->GetDZ(),  
"half length in Z");
 
  619    AddText(pt,
"fPhi1",tubeseg->GetPhi1(),
"first phi limit");
 
  620    AddText(pt,
"fPhi2",tubeseg->GetPhi2(),
"second phi limit");
 
  621    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  623    pt->SetTextAlign(12);
 
  624    pt->SetTextSize(0.044);
 
  631 void cone(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  633    gROOT->GetListOfCanvases()->Delete();
 
  634    if (iaxis<0 || iaxis>3) {
 
  635       printf(
"Wrong division axis. Range is 1-3.\n");
 
  639       printf(
"cannot divide cone on Rxy\n");
 
  642    TCanvas *c = 
new TCanvas(
"cone shape", 
"A cone", 700,1000);
 
  646       gPad->SetPad(0,0,1,0.4);
 
  648       gPad->SetPad(0,0.4,1,1);
 
  650    if (gGeoManager) 
delete gGeoManager;
 
  651    new TGeoManager(
"cone", 
"poza4");
 
  652    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  653    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  654    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  655    gGeoManager->SetTopVolume(top);
 
  656    TGeoVolume *vol = gGeoManager->MakeCone(
"CONE",med, 40,10,20,35,45);
 
  657    vol->SetLineColor(randomColor());
 
  658    vol->SetLineWidth(2);
 
  660       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  662       slice->SetLineColor(randomColor());
 
  665    gGeoManager->CloseGeometry();
 
  666    gGeoManager->SetNsegments(80);
 
  669    if (!comments) 
return;
 
  671    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  673    TGeoCone *cone = (TGeoCone*)(vol->GetShape());
 
  674    TText *text = pt->AddText(
"TGeoCone - cone class");
 
  675    text->SetTextColor(2);
 
  676    AddText(pt,
"fDZ",  cone->GetDZ(),    
"half length in Z");
 
  677    AddText(pt,
"fRmin1",cone->GetRmin1(),
"inner radius at -dz");
 
  678    AddText(pt,
"fRmax1",cone->GetRmax1(),
"outer radius at -dz");
 
  679    AddText(pt,
"fRmin2",cone->GetRmin2(),
"inner radius at +dz");
 
  680    AddText(pt,
"fRmax2",cone->GetRmax2(),
"outer radius at +dz");
 
  681    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  682    pt->AddText(
"Execute: cone(iaxis, ndiv, start, step) to divide this.");
 
  683    pt->AddText(
"----- IAXIS can be 2 or 3 (Phi, Z)");
 
  684    pt->AddText(
"----- NDIV must be a positive integer");
 
  685    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
  686    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
  687    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
  689    pt->SetAllWith(
"-----",
"color",2);
 
  690    pt->SetAllWith(
"-----",
"font",72);
 
  691    pt->SetAllWith(
"-----",
"size",0.04);
 
  692    pt->SetAllWith(
"Execute",
"color",4);
 
  693    pt->SetTextAlign(12);
 
  694    pt->SetTextSize(0.044);
 
  701 void coneseg(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  703    gROOT->GetListOfCanvases()->Delete();
 
  704    if (iaxis<0 || iaxis>3) {
 
  705       printf(
"Wrong division axis. Range is 1-3.\n");
 
  708    TCanvas *c = 
new TCanvas(
"coneseg shape", 
"A cone segment", 700,1000);
 
  712       gPad->SetPad(0,0,1,0.4);
 
  714       gPad->SetPad(0,0.4,1,1);
 
  716    if (gGeoManager) 
delete gGeoManager;
 
  717    new TGeoManager(
"coneseg", 
"poza5");
 
  718    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  719    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  720    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  721    gGeoManager->SetTopVolume(top);
 
  722    TGeoVolume *vol = gGeoManager->MakeCons(
"CONESEG",med, 40,30,40,10,20,-30,250);
 
  723    vol->SetLineColor(randomColor());
 
  727       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  729       slice->SetLineColor(randomColor());
 
  731    gGeoManager->CloseGeometry();
 
  732    gGeoManager->SetNsegments(80);
 
  735    if (!comments) 
return;
 
  737    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  739    TGeoConeSeg *coneseg = (TGeoConeSeg*)(vol->GetShape());
 
  740    TText *text = pt->AddText(
"TGeoConeSeg - coneseg class");
 
  741    text->SetTextColor(2);
 
  742    AddText(pt,
"fDZ",  coneseg->GetDZ(),    
"half length in Z");
 
  743    AddText(pt,
"fRmin1",coneseg->GetRmin1(),
"inner radius at -dz");
 
  744    AddText(pt,
"fRmax1",coneseg->GetRmax1(),
"outer radius at -dz");
 
  745    AddText(pt,
"fRmin2",coneseg->GetRmin1(),
"inner radius at +dz");
 
  746    AddText(pt,
"fRmax2",coneseg->GetRmax1(),
"outer radius at +dz");
 
  747    AddText(pt,
"fPhi1",coneseg->GetPhi1(),
"first phi limit");
 
  748    AddText(pt,
"fPhi2",coneseg->GetPhi2(),
"second phi limit");
 
  749    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  750    pt->AddText(
"Execute: coneseg(iaxis, ndiv, start, step) to divide this.");
 
  751    pt->AddText(
"----- IAXIS can be 2 or 3 (Phi, Z)");
 
  752    pt->AddText(
"----- NDIV must be a positive integer");
 
  753    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
  754    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
  755    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
  757    pt->SetAllWith(
"-----",
"color",2);
 
  758    pt->SetAllWith(
"-----",
"font",72);
 
  759    pt->SetAllWith(
"-----",
"size",0.04);
 
  760    pt->SetAllWith(
"Execute",
"color",4);
 
  761    pt->SetTextAlign(12);
 
  762    pt->SetTextSize(0.044);
 
  769 void eltu(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  771    gROOT->GetListOfCanvases()->Delete();
 
  772    TCanvas *c = 
new TCanvas(
"eltu shape", 
"An Elliptical tube", 700,1000);
 
  776       gPad->SetPad(0,0,1,0.4);
 
  778       gPad->SetPad(0,0.4,1,1);
 
  780    if (gGeoManager) 
delete gGeoManager;
 
  781    new TGeoManager(
"eltu", 
"poza6");
 
  782    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  783    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  784    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  785    gGeoManager->SetTopVolume(top);
 
  786    TGeoVolume *vol = gGeoManager->MakeEltu(
"ELTU",med, 30,10,40);
 
  787    vol->SetLineColor(randomColor());
 
  791       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  793       slice->SetLineColor(randomColor());
 
  795    gGeoManager->CloseGeometry();
 
  796    gGeoManager->SetNsegments(80);
 
  799    if (!comments) 
return;
 
  801    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  803    TGeoEltu *eltu = (TGeoEltu*)(vol->GetShape());
 
  804    TText *text = pt->AddText(
"TGeoEltu - eltu class");
 
  805    text->SetTextColor(2);
 
  806    AddText(pt,
"fA",eltu->GetA(), 
"semi-axis along x");
 
  807    AddText(pt,
"fB",eltu->GetB(), 
"semi-axis along y");
 
  808    AddText(pt,
"fDZ", eltu->GetDZ(),  
"half length in Z");
 
  809    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  810    pt->AddText(
"Execute: eltu(iaxis, ndiv, start, step) to divide this.");
 
  811    pt->AddText(
"----- IAXIS can be 2 or 3 (Phi, Z)");
 
  812    pt->AddText(
"----- NDIV must be a positive integer");
 
  813    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
  814    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
  815    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
  817    pt->SetAllWith(
"-----",
"color",2);
 
  818    pt->SetAllWith(
"-----",
"font",72);
 
  819    pt->SetAllWith(
"-----",
"size",0.04);
 
  820    pt->SetAllWith(
"Execute",
"color",4);
 
  821    pt->SetTextAlign(12);
 
  822    pt->SetTextSize(0.044);
 
  829 void sphere(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  831    gROOT->GetListOfCanvases()->Delete();
 
  833       printf(
"Cannot divide spheres\n");
 
  836    TCanvas *c = 
new TCanvas(
"Sphere shap", 
"A spherical sector", 700,1000);
 
  840       gPad->SetPad(0,0,1,0.4);
 
  842       gPad->SetPad(0,0.4,1,1);
 
  844    if (gGeoManager) 
delete gGeoManager;
 
  845    new TGeoManager(
"sphere", 
"poza7");
 
  846    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  847    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  848    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  849    gGeoManager->SetTopVolume(top);
 
  850    TGeoVolume *vol = gGeoManager->MakeSphere(
"SPHERE",med, 30,40,60,120,30,240);
 
  851    vol->SetLineColor(randomColor());
 
  852    vol->SetLineWidth(2);
 
  855       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  857       slice->SetLineColor(randomColor());
 
  859    gGeoManager->CloseGeometry();
 
  860    gGeoManager->SetNsegments(80);
 
  863    if (!comments) 
return;
 
  865    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  867    TGeoSphere *sphere = (TGeoSphere*)(vol->GetShape());
 
  868    TText *text = pt->AddText(
"TGeoSphere- sphere class");
 
  869    text->SetTextColor(2);
 
  870    AddText(pt,
"fRmin",sphere->GetRmin(),
"inner radius");
 
  871    AddText(pt,
"fRmax",sphere->GetRmax(),
"outer radius");
 
  872    AddText(pt,
"fTheta1",sphere->GetTheta1(),
"lower theta limit");
 
  873    AddText(pt,
"fTheta2",sphere->GetTheta2(),
"higher theta limit");
 
  874    AddText(pt,
"fPhi1",sphere->GetPhi1(),
"lower phi limit");
 
  875    AddText(pt,
"fPhi2",sphere->GetPhi2(),
"higher phi limit");
 
  876    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  878    pt->SetTextSize(0.044);
 
  885 void torus(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  887    gROOT->GetListOfCanvases()->Delete();
 
  889       printf(
"Cannot divide a torus\n");
 
  892    TCanvas *c = 
new TCanvas(
"torus shape", 
"A toroidal segment", 700,1000);
 
  896       gPad->SetPad(0,0,1,0.4);
 
  898       gPad->SetPad(0,0.4,1,1);
 
  900    if (gGeoManager) 
delete gGeoManager;
 
  901    new TGeoManager(
"torus", 
"poza2");
 
  902    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  903    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  904    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  905    gGeoManager->SetTopVolume(top);
 
  906    TGeoVolume *vol = gGeoManager->MakeTorus(
"TORUS",med, 40,20,25,0,270);
 
  907    vol->SetLineColor(randomColor());
 
  910       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  912       slice->SetLineColor(2);
 
  914    gGeoManager->CloseGeometry();
 
  915    gGeoManager->SetNsegments(80);
 
  918    if (!comments) 
return;
 
  920    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  922    TGeoTorus *tor = (TGeoTorus*)(vol->GetShape());
 
  923    TText *text = pt->AddText(
"TGeoTorus - torus class");
 
  924    text->SetTextColor(2);
 
  925    AddText(pt,
"fR",tor->GetR(),
"radius of the ring");
 
  926    AddText(pt,
"fRmin",tor->GetRmin(),
"minimum radius");
 
  927    AddText(pt,
"fRmax",tor->GetRmax(),
"maximum radius");
 
  928    AddText(pt,
"fPhi1",  tor->GetPhi1(),  
"starting phi angle");
 
  929    AddText(pt,
"fDphi",  tor->GetDphi(),  
"phi range");
 
  930    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  932    pt->SetTextSize(0.044);
 
  938 void trd1(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
  940    gROOT->GetListOfCanvases()->Delete();
 
  941    if (iaxis<0 || iaxis>3) {
 
  942       printf(
"Wrong division axis. Range is 1-3.\n");
 
  946       printf(
"Cannot divide trd1 on X axis\n");
 
  950    TCanvas *c = 
new TCanvas(
"trd1 shape", 
"A trapezoid with dX varying", 700,1000);
 
  954       gPad->SetPad(0,0,1,0.4);
 
  956       gPad->SetPad(0,0.4,1,1);
 
  958    if (gGeoManager) 
delete gGeoManager;
 
  959    new TGeoManager(
"trd1", 
"poza8");
 
  960    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
  961    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
  962    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
  963    gGeoManager->SetTopVolume(top);
 
  964    TGeoVolume *vol = gGeoManager->MakeTrd1(
"Trd1",med, 10,20,30,40);
 
  965    vol->SetLineColor(randomColor());
 
  966    vol->SetLineWidth(2);
 
  969       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
  971       slice->SetLineColor(randomColor());
 
  973    gGeoManager->CloseGeometry();
 
  974    gGeoManager->SetNsegments(80);
 
  977    if (!comments) 
return;
 
  979    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
  981    TGeoTrd1 *trd1 = (TGeoTrd1*)(vol->GetShape());
 
  982    TText *text = pt->AddText(
"TGeoTrd1 - Trd1 class");
 
  983    text->SetTextColor(2);
 
  984    AddText(pt,
"fDx1",trd1->GetDx1(),
"half length in X at lower Z surface(-dz)");
 
  985    AddText(pt,
"fDx2",trd1->GetDx2(),
"half length in X at higher Z surface(+dz)");
 
  986    AddText(pt,
"fDy",trd1->GetDy(),
"half length in Y");
 
  987    AddText(pt,
"fDz",trd1->GetDz(),
"half length in Z");
 
  988    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
  989    pt->AddText(
"Execute: trd1(iaxis, ndiv, start, step) to divide this.");
 
  990    pt->AddText(
"----- IAXIS can be 2 or 3 (Y, Z)");
 
  991    pt->AddText(
"----- NDIV must be a positive integer");
 
  992    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
  993    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
  994    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
  996    pt->SetAllWith(
"-----",
"color",2);
 
  997    pt->SetAllWith(
"-----",
"font",72);
 
  998    pt->SetAllWith(
"-----",
"size",0.04);
 
  999    pt->SetAllWith(
"Execute",
"color",4);
 
 1000    pt->SetTextAlign(12);
 
 1001    pt->SetTextSize(0.044);
 
 1010    gROOT->GetListOfCanvases()->Delete();
 
 1011    TCanvas *c = 
new TCanvas(
"parab shape", 
"A paraboloid segment", 700,1000);
 
 1015       gPad->SetPad(0,0,1,0.4);
 
 1017       gPad->SetPad(0,0.4,1,1);
 
 1019    if (gGeoManager) 
delete gGeoManager;
 
 1020    new TGeoManager(
"parab", 
"paraboloid");
 
 1021    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1022    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1023    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
 1024    gGeoManager->SetTopVolume(top);
 
 1025    TGeoVolume *vol = gGeoManager->MakeParaboloid(
"PARAB",med,0, 40, 50);
 
 1026    TGeoParaboloid *par = (TGeoParaboloid*)vol->GetShape();
 
 1027    vol->SetLineColor(randomColor());
 
 1028    vol->SetLineWidth(2);
 
 1029    top->AddNode(vol,1);
 
 1030    gGeoManager->CloseGeometry();
 
 1031    gGeoManager->SetNsegments(80);
 
 1034    if (!comments) 
return;
 
 1036    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1037    pt->SetLineColor(1);
 
 1038    TText *text = pt->AddText(
"TGeoParaboloid - Paraboloid class");
 
 1039    text->SetTextColor(2);
 
 1040    AddText(pt,
"fRlo",par->GetRlo(),
"radius at Z=-dz");
 
 1041    AddText(pt,
"fRhi",par->GetRhi(),
"radius at Z=+dz");
 
 1042    AddText(pt,
"fDz",par->GetDz(),
"half-length on Z axis");
 
 1043    pt->AddText(
"----- A paraboloid is described by the equation:");
 
 1044    pt->AddText(
"-----    z = a*r*r + b;   where: r = x*x + y*y");
 
 1045    pt->AddText(
"----- Create with:    TGeoParaboloid *parab = new TGeoParaboloid(rlo, rhi, dz);");
 
 1046    pt->AddText(
"-----    dz:  half-length in Z (range from -dz to +dz");
 
 1047    pt->AddText(
"-----    rlo: radius at z=-dz given by: -dz = a*rlo*rlo + b");
 
 1048    pt->AddText(
"-----    rhi: radius at z=+dz given by:  dz = a*rhi*rhi + b");
 
 1049    pt->AddText(
"-----      rlo != rhi; both >= 0");
 
 1051    pt->SetAllWith(
"-----",
"color",2);
 
 1052    pt->SetAllWith(
"-----",
"font",72);
 
 1053    pt->SetAllWith(
"-----",
"size",0.04);
 
 1054    pt->SetTextAlign(12);
 
 1055    pt->SetTextSize(0.044);
 
 1063    gROOT->GetListOfCanvases()->Delete();
 
 1064    TCanvas *c = 
new TCanvas(
"hype shape", 
"A hyperboloid", 700,1000);
 
 1068       gPad->SetPad(0,0,1,0.4);
 
 1070       gPad->SetPad(0,0.4,1,1);
 
 1072    if (gGeoManager) 
delete gGeoManager;
 
 1073    new TGeoManager(
"hype", 
"hyperboloid");
 
 1074    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1075    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1076    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
 1077    gGeoManager->SetTopVolume(top);
 
 1078    TGeoVolume *vol = gGeoManager->MakeHype(
"HYPE",med,10, 45 ,20,45,40);
 
 1079    TGeoHype *hype = (TGeoHype*)vol->GetShape();
 
 1080    vol->SetLineColor(randomColor());
 
 1081    vol->SetLineWidth(2);
 
 1082    top->AddNode(vol,1);
 
 1083    gGeoManager->CloseGeometry();
 
 1084    gGeoManager->SetNsegments(80);
 
 1087    if (!comments) 
return;
 
 1089    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1090    pt->SetLineColor(1);
 
 1091    TText *text = pt->AddText(
"TGeoHype - Hyperboloid class");
 
 1092    text->SetTextColor(2);
 
 1093    AddText(pt,
"fRmin",hype->GetRmin(),
"minimum inner radius");
 
 1094    AddText(pt,
"fStIn",hype->GetStIn(),
"inner surface stereo angle [deg]");
 
 1095    AddText(pt,
"fRmax",hype->GetRmax(),
"minimum outer radius");
 
 1096    AddText(pt,
"fStOut",hype->GetStOut(),
"outer surface stereo angle [deg]");
 
 1097    AddText(pt,
"fDz",hype->GetDz(),
"half-length on Z axis");
 
 1098    pt->AddText(
"----- A hyperboloid is described by the equation:");
 
 1099    pt->AddText(
"-----    r^2 - (tan(stereo)*z)^2 = rmin^2;   where: r = x*x + y*y");
 
 1100    pt->AddText(
"----- Create with:    TGeoHype *hype = new TGeoHype(rin, stin, rout, stout, dz);");
 
 1101    pt->AddText(
"-----      rin < rout; rout > 0");
 
 1102    pt->AddText(
"-----      rin = 0; stin > 0 => inner surface conical");
 
 1103    pt->AddText(
"-----      stin/stout = 0 => corresponding surface cylindrical");
 
 1105    pt->SetAllWith(
"-----",
"color",2);
 
 1106    pt->SetAllWith(
"-----",
"font",72);
 
 1107    pt->SetAllWith(
"-----",
"size",0.04);
 
 1108    pt->SetTextAlign(12);
 
 1109    pt->SetTextSize(0.044);
 
 1114 void pcon(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
 1116    gROOT->GetListOfCanvases()->Delete();
 
 1117    if (iaxis<0 || iaxis>3) {
 
 1118       printf(
"Wrong division axis. Range is 1-3.\n");
 
 1122       printf(
"Cannot divide pcon on Rxy\n");
 
 1125    TCanvas *c = 
new TCanvas(
"pcon shape", 
"A polycone", 700,1000);
 
 1129       gPad->SetPad(0,0,1,0.4);
 
 1131       gPad->SetPad(0,0.4,1,1);
 
 1133    if (gGeoManager) 
delete gGeoManager;
 
 1134    new TGeoManager(
"pcon", 
"poza10");
 
 1135    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1136    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1137    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
 1138    gGeoManager->SetTopVolume(top);
 
 1139    TGeoVolume *vol = gGeoManager->MakePcon(
"PCON",med, -30.0,300,4);
 
 1140    TGeoPcon *pcon = (TGeoPcon*)(vol->GetShape());
 
 1141    pcon->DefineSection(0,0,15,20);
 
 1142    pcon->DefineSection(1,20,15,20);
 
 1143    pcon->DefineSection(2,20,15,25);
 
 1144    pcon->DefineSection(3,50,15,20);
 
 1145    vol->SetLineColor(randomColor());
 
 1146    vol->SetLineWidth(2);
 
 1147    top->AddNode(vol,1);
 
 1149       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
 1151       slice->SetLineColor(randomColor());
 
 1153    gGeoManager->CloseGeometry();
 
 1154    gGeoManager->SetNsegments(80);
 
 1157    if (!comments) 
return;
 
 1159    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1160    pt->SetLineColor(1);
 
 1161    TText *text = pt->AddText(
"TGeoPcon - pcon class");
 
 1162    text->SetTextColor(2);
 
 1163    AddText(pt,
"fPhi1",pcon->GetPhi1(),
"lower phi limit");
 
 1164    AddText(pt,
"fDphi",pcon->GetDphi(),
"phi range");
 
 1165    AddText(pt,
"fNz",pcon->GetNz(),
"number of z planes");
 
 1166    for (Int_t j=0; j<pcon->GetNz(); j++) {
 
 1168       sprintf(line, 
"fZ[%i]=%5.2f  fRmin[%i]=%5.2f  fRmax[%i]=%5.2f",
 
 1169               j,pcon->GetZ()[j],j,pcon->GetRmin()[j],j,pcon->GetRmax()[j]);
 
 1170       text = pt->AddText(line);
 
 1171       text->SetTextColor(4);
 
 1172       text->SetTextAlign(12);
 
 1174    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
 1175    pt->AddText(
"Execute: pcon(iaxis, ndiv, start, step) to divide this.");
 
 1176    pt->AddText(
"----- IAXIS can be 2 or 3 (Phi, Z)");
 
 1177    pt->AddText(
"----- NDIV must be a positive integer");
 
 1178    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
 1179    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
 1180    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
 1182    pt->SetAllWith(
"-----",
"color",2);
 
 1183    pt->SetAllWith(
"-----",
"font",72);
 
 1184    pt->SetAllWith(
"-----",
"size",0.04);
 
 1185    pt->SetAllWith(
"Execute",
"color",4);
 
 1186    pt->SetTextAlign(12);
 
 1187    pt->SetTextSize(0.044);
 
 1194 void pgon(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
 1196    gROOT->GetListOfCanvases()->Delete();
 
 1197    if (iaxis<0 || iaxis>3) {
 
 1198       printf(
"Wrong division axis. Range is 1-3.\n");
 
 1202       printf(
"Cannot divide pgon on Rxy\n");
 
 1205    TCanvas *c = 
new TCanvas(
"pgon shape", 
"A polygone", 700,1000);
 
 1209       gPad->SetPad(0,0,1,0.4);
 
 1211       gPad->SetPad(0,0.4,1,1);
 
 1213    if (gGeoManager) 
delete gGeoManager;
 
 1214    new TGeoManager(
"pgon", 
"poza11");
 
 1215    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1216    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1217    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,150,150,100);
 
 1218    gGeoManager->SetTopVolume(top);
 
 1219    TGeoVolume *vol = gGeoManager->MakePgon(
"PGON",med, -45.0,270.0,4,4);
 
 1220    TGeoPgon *pgon = (TGeoPgon*)(vol->GetShape());
 
 1221    pgon->DefineSection(0,-70,45,50);
 
 1222    pgon->DefineSection(1,0,35,40);
 
 1223    pgon->DefineSection(2,0,30,35);
 
 1224    pgon->DefineSection(3,70,90,100);
 
 1225    vol->SetLineColor(randomColor());
 
 1226    vol->SetLineWidth(2);
 
 1227    top->AddNode(vol,1);
 
 1229       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
 1231       slice->SetLineColor(randomColor());
 
 1233    gGeoManager->CloseGeometry();
 
 1234    gGeoManager->SetNsegments(80);
 
 1237    if (!comments) 
return;
 
 1239    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1240    pt->SetLineColor(1);
 
 1241    TText *text = pt->AddText(
"TGeoPgon - pgon class");
 
 1242    text->SetTextColor(2);
 
 1243    AddText(pt,
"fPhi1",pgon->GetPhi1(),
"lower phi limit");
 
 1244    AddText(pt,
"fDphi",pgon->GetDphi(),
"phi range");
 
 1245    AddText(pt,
"fNedges",pgon->GetNedges(),
"number of edges");
 
 1246     AddText(pt,
"fNz",pgon->GetNz(),
"number of z planes");
 
 1247    for (Int_t j=0; j<pgon->GetNz(); j++) {
 
 1249       sprintf(line, 
"fZ[%i]=%5.2f  fRmin[%i]=%5.2f  fRmax[%i]=%5.2f",
 
 1250               j,pgon->GetZ()[j],j,pgon->GetRmin()[j],j,pgon->GetRmax()[j]);
 
 1251       text = pt->AddText(line);
 
 1252       text->SetTextColor(4);
 
 1253       text->SetTextAlign(12);
 
 1255    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
 1256    pt->AddText(
"Execute: pgon(iaxis, ndiv, start, step) to divide this.");
 
 1257    pt->AddText(
"----- IAXIS can be 2 or 3 (Phi, Z)");
 
 1258    pt->AddText(
"----- NDIV must be a positive integer");
 
 1259    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
 1260    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
 1261    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
 1263    pt->SetAllWith(
"-----",
"color",2);
 
 1264    pt->SetAllWith(
"-----",
"font",72);
 
 1265    pt->SetAllWith(
"-----",
"size",0.04);
 
 1266    pt->SetAllWith(
"Execute",
"color",4);
 
 1267    pt->SetTextAlign(12);
 
 1268    pt->SetTextSize(0.044);
 
 1269    pt->SetTextSize(0.044);
 
 1276 void arb8(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
 1278    gROOT->GetListOfCanvases()->Delete();
 
 1280       printf(
"Cannot divide arb8\n");
 
 1283    TCanvas *c = 
new TCanvas(
"arb8 shape", 
"An arbitrary polyhedron", 700,1000);
 
 1287       gPad->SetPad(0,0,1,0.4);
 
 1289       gPad->SetPad(0,0.4,1,1);
 
 1291    if (gGeoManager) 
delete gGeoManager;
 
 1292    new TGeoManager(
"arb8", 
"poza12");
 
 1293    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1294    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1295    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
 1296    gGeoManager->SetTopVolume(top);
 
 1297    TGeoArb8 *arb = 
new TGeoArb8(20);
 
 1298    arb->SetVertex(0,-30,-25);
 
 1299    arb->SetVertex(1,-25,25);
 
 1300    arb->SetVertex(2,5,25);
 
 1301    arb->SetVertex(3,25,-25);
 
 1302    arb->SetVertex(4,-28,-23);
 
 1303    arb->SetVertex(5,-23,27);
 
 1304    arb->SetVertex(6,-23,27);
 
 1305    arb->SetVertex(7,13,-27);
 
 1306    TGeoVolume *vol = 
new TGeoVolume(
"ARB8",arb,med);
 
 1307    vol->SetLineColor(randomColor());
 
 1308    vol->SetLineWidth(2);
 
 1309    top->AddNode(vol,1);
 
 1311       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
 1313       slice->SetLineColor(randomColor());
 
 1315    gGeoManager->CloseGeometry();
 
 1316    gGeoManager->SetNsegments(80);
 
 1319    if (!comments) 
return;
 
 1321    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1322    pt->SetLineColor(1);
 
 1323    TText *text = pt->AddText(
"TGeoArb8 - arb8 class");
 
 1324    text->SetTextColor(2);
 
 1325    AddText(pt,
"fDz",arb->GetDz(),
"Z half length");
 
 1327    Double_t *vert = arb->GetVertices();
 
 1328    text = pt->AddText(
"Vertices on lower Z plane:");
 
 1329    text->SetTextColor(3);
 
 1331    for (i=0; i<4; i++) {
 
 1332       sprintf(line,
"   fXY[%d] = (%5.2f, %5.2f)", i, vert[2*i], vert[2*i+1]);
 
 1333       text = pt->AddText(line);
 
 1334       text->SetTextSize(0.043);
 
 1335       text->SetTextColor(4);
 
 1337    text = pt->AddText(
"Vertices on higher Z plane:");
 
 1338    text->SetTextColor(3);
 
 1339    for (i=4; i<8; i++) {
 
 1340       sprintf(line,
"   fXY[%d] = (%5.2f, %5.2f)", i, vert[2*i], vert[2*i+1]);
 
 1341       text = pt->AddText(line);
 
 1342       text->SetTextSize(0.043);
 
 1343       text->SetTextColor(4);
 
 1346    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
 1348    pt->SetTextSize(0.043);
 
 1355 void trd2(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
 1357    gROOT->GetListOfCanvases()->Delete();
 
 1358    if (iaxis && iaxis!=3) {
 
 1359       printf(
"Wrong division axis. Can divide only in Z (3)\n");
 
 1362    TCanvas *c = 
new TCanvas(
"trd2 shape", 
"A trapezoid with dX and dY varying with Z", 700,1000);
 
 1366       gPad->SetPad(0,0,1,0.4);
 
 1368       gPad->SetPad(0,0.4,1,1);
 
 1370    if (gGeoManager) 
delete gGeoManager;
 
 1371    new TGeoManager(
"trd2", 
"poza9");
 
 1372    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1373    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1374    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
 1375    gGeoManager->SetTopVolume(top);
 
 1376    TGeoVolume *vol = gGeoManager->MakeTrd2(
"Trd2",med, 10,20,30,10,40);
 
 1377    vol->SetLineColor(randomColor());
 
 1378    vol->SetLineWidth(2);
 
 1379    top->AddNode(vol,1);
 
 1381       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
 1383       slice->SetLineColor(randomColor());
 
 1385    gGeoManager->CloseGeometry();
 
 1386    gGeoManager->SetNsegments(80);
 
 1389    if (!comments) 
return;
 
 1391    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1392    pt->SetLineColor(1);
 
 1393    TGeoTrd2 *trd2 = (TGeoTrd2*)(vol->GetShape());
 
 1394    TText *text = pt->AddText(
"TGeoTrd2 - Trd2 class");
 
 1395    text->SetTextColor(2);
 
 1396    AddText(pt,
"fDx1",trd2->GetDx1(),
"half length in X at lower Z surface(-dz)");
 
 1397    AddText(pt,
"fDx2",trd2->GetDx2(),
"half length in X at higher Z surface(+dz)");
 
 1398    AddText(pt,
"fDy1",trd2->GetDy1(),
"half length in Y at lower Z surface(-dz)");
 
 1399    AddText(pt,
"fDy2",trd2->GetDy2(),
"half length in Y at higher Z surface(-dz)");
 
 1400    AddText(pt,
"fDz",trd2->GetDz(),
"half length in Z");
 
 1401    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
 1402    pt->AddText(
"Execute: trd2(iaxis, ndiv, start, step) to divide this.");
 
 1403    pt->AddText(
"----- IAXIS can be only 3 (Z)");
 
 1404    pt->AddText(
"----- NDIV must be a positive integer");
 
 1405    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
 1406    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
 1407    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
 1409    pt->SetAllWith(
"-----",
"color",2);
 
 1410    pt->SetAllWith(
"-----",
"font",72);
 
 1411    pt->SetAllWith(
"-----",
"size",0.04);
 
 1412    pt->SetAllWith(
"Execute",
"color",4);
 
 1413    pt->SetTextAlign(12);
 
 1414    pt->SetTextSize(0.044);
 
 1421 void trap(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
 1423    gROOT->GetListOfCanvases()->Delete();
 
 1424    if (iaxis && iaxis!=3) {
 
 1425       printf(
"Wrong division axis. Can divide only in Z (3)\n");
 
 1428    TCanvas *c = 
new TCanvas(
"trap shape", 
"A more general trapezoid", 700,1000);
 
 1432       gPad->SetPad(0,0,1,0.4);
 
 1434       gPad->SetPad(0,0.4,1,1);
 
 1436    if (gGeoManager) 
delete gGeoManager;
 
 1437    new TGeoManager(
"trap", 
"poza10");
 
 1438    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1439    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1440    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
 1441    gGeoManager->SetTopVolume(top);
 
 1442    TGeoVolume *vol = gGeoManager->MakeTrap(
"Trap",med, 30,15,30,20,10,15,0,20,10,15,0);
 
 1443    vol->SetLineColor(randomColor());
 
 1444    vol->SetLineWidth(2);
 
 1445    top->AddNode(vol,1);
 
 1447       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
 1449       slice->SetLineColor(randomColor());
 
 1451    gGeoManager->CloseGeometry();
 
 1452    gGeoManager->SetNsegments(80);
 
 1455    if (!comments) 
return;
 
 1457    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1458    pt->SetLineColor(1);
 
 1459    TGeoTrap *trap = (TGeoTrap*)(vol->GetShape());
 
 1460    TText *text = pt->AddText(
"TGeoTrap - Trapezoid class");
 
 1461    text->SetTextColor(2);
 
 1462    AddText(pt,
"fDz",trap->GetDz(),
"half length in Z");
 
 1463    AddText(pt,
"fTheta",trap->GetTheta(),
"theta angle of trapezoid axis");
 
 1464    AddText(pt,
"fPhi",trap->GetPhi(),
"phi angle of trapezoid axis");
 
 1465    AddText(pt,
"fH1",trap->GetH1(),
"half length in y at -fDz");
 
 1466    AddText(pt,
"fAlpha1",trap->GetAlpha1(),
"angle between centers of x edges and y axis at -fDz");
 
 1467    AddText(pt,
"fBl1",trap->GetBl1(),
"half length in x at -dZ and y=-fH1");
 
 1468    AddText(pt,
"fTl1",trap->GetTl1(),
"half length in x at -dZ and y=+fH1");
 
 1469    AddText(pt,
"fH2",trap->GetH2(),
"half length in y at +fDz");
 
 1470    AddText(pt,
"fBl2",trap->GetBl2(),
"half length in x at +dZ and y=-fH1");
 
 1471    AddText(pt,
"fTl2",trap->GetTl2(),
"half length in x at +dZ and y=+fH1");
 
 1472    AddText(pt,
"fAlpha2",trap->GetAlpha2(),
"angle between centers of x edges and y axis at +fDz");
 
 1473    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
 1474    pt->AddText(
"Execute: trap(iaxis, ndiv, start, step) to divide this.");
 
 1475    pt->AddText(
"----- IAXIS can be only 3 (Z)");
 
 1476    pt->AddText(
"----- NDIV must be a positive integer");
 
 1477    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
 1478    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
 1479    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
 1481    pt->SetAllWith(
"-----",
"color",2);
 
 1482    pt->SetAllWith(
"-----",
"font",72);
 
 1483    pt->SetAllWith(
"-----",
"size",0.04);
 
 1484    pt->SetAllWith(
"Execute",
"color",4);
 
 1485    pt->SetTextAlign(12);
 
 1486    pt->SetTextSize(0.044);
 
 1493 void gtra(Int_t iaxis=0, Int_t ndiv=8, Double_t start=0, Double_t step=0)
 
 1495    gROOT->GetListOfCanvases()->Delete();
 
 1496    if (iaxis && iaxis!=3) {
 
 1497       printf(
"Wrong division axis. Can divide only in Z (3)\n");
 
 1500    TCanvas *c = 
new TCanvas(
"gtra shape", 
"A twisted trapezoid", 700,1000);
 
 1504       gPad->SetPad(0,0,1,0.4);
 
 1506       gPad->SetPad(0,0.4,1,1);
 
 1508    if (gGeoManager) 
delete gGeoManager;
 
 1509    new TGeoManager(
"gtra", 
"poza11");
 
 1510    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1511    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1512    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
 1513    gGeoManager->SetTopVolume(top);
 
 1514    TGeoVolume *vol = gGeoManager->MakeGtra(
"Gtra",med, 30,15,30,30,20,10,15,0,20,10,15,0);
 
 1515    vol->SetLineColor(randomColor());
 
 1516    vol->SetLineWidth(2);
 
 1517    top->AddNode(vol,1);
 
 1519       TGeoVolume *slice = vol->Divide(
"SLICE",iaxis,ndiv,start,step);
 
 1521       slice->SetLineColor(randomColor());
 
 1523    gGeoManager->CloseGeometry();
 
 1524    gGeoManager->SetNsegments(80);
 
 1527    if (!comments) 
return;
 
 1529    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1530    pt->SetLineColor(1);
 
 1531    TGeoGtra *trap = (TGeoGtra*)(vol->GetShape());
 
 1532    TText *text = pt->AddText(
"TGeoGtra - Twisted trapezoid class");
 
 1533    text->SetTextColor(2);
 
 1534    AddText(pt,
"fDz",trap->GetDz(),
"half length in Z");
 
 1535    AddText(pt,
"fTheta",trap->GetTheta(),
"theta angle of trapezoid axis");
 
 1536    AddText(pt,
"fPhi",trap->GetPhi(),
"phi angle of trapezoid axis");
 
 1537    AddText(pt,
"fTwist",trap->GetTwistAngle(), 
"twist angle");
 
 1538    AddText(pt,
"fH1",trap->GetH1(),
"half length in y at -fDz");
 
 1539    AddText(pt,
"fAlpha1",trap->GetAlpha1(),
"angle between centers of x edges and y axis at -fDz");
 
 1540    AddText(pt,
"fBl1",trap->GetBl1(),
"half length in x at -dZ and y=-fH1");
 
 1541    AddText(pt,
"fTl1",trap->GetTl1(),
"half length in x at -dZ and y=+fH1");
 
 1542    AddText(pt,
"fH2",trap->GetH2(),
"half length in y at +fDz");
 
 1543    AddText(pt,
"fBl2",trap->GetBl2(),
"half length in x at +dZ and y=-fH1");
 
 1544    AddText(pt,
"fTl2",trap->GetTl2(),
"half length in x at +dZ and y=+fH1");
 
 1545    AddText(pt,
"fAlpha2",trap->GetAlpha2(),
"angle between centers of x edges and y axis at +fDz");
 
 1546    if (iaxis) AddText(pt, vol->GetFinder(), iaxis);
 
 1547    pt->AddText(
"Execute: gtra(iaxis, ndiv, start, step) to divide this.");
 
 1548    pt->AddText(
"----- IAXIS can be only 3 (Z)");
 
 1549    pt->AddText(
"----- NDIV must be a positive integer");
 
 1550    pt->AddText(
"----- START must be a valid axis offset within shape range on divided axis");
 
 1551    pt->AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
 
 1552    pt->AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
 
 1554    pt->SetAllWith(
"-----",
"color",2);
 
 1555    pt->SetAllWith(
"-----",
"font",72);
 
 1556    pt->SetAllWith(
"-----",
"size",0.04);
 
 1557    pt->SetAllWith(
"Execute",
"color",4);
 
 1558    pt->SetTextAlign(12);
 
 1559    pt->SetTextSize(0.044);
 
 1568    gROOT->GetListOfCanvases()->Delete();
 
 1569    TCanvas *c = 
new TCanvas(
"gtra shape", 
"A twisted trapezoid", 700,1000);
 
 1573       gPad->SetPad(0,0,1,0.4);
 
 1575       gPad->SetPad(0,0.4,1,1);
 
 1577    if (gGeoManager) 
delete gGeoManager;
 
 1578    new TGeoManager(
"xtru", 
"poza12");
 
 1579    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1580    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1581    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
 1582    gGeoManager->SetTopVolume(top);
 
 1583    TGeoVolume *vol = gGeoManager->MakeXtru(
"XTRU",med,4);
 
 1584    TGeoXtru *xtru = (TGeoXtru*)vol->GetShape();
 
 1585    Double_t x[8] = {-30,-30,30,30,15,15,-15,-15};
 
 1586    Double_t y[8] = {-30,30,30,-30,-30,15,15,-30};
 
 1587    xtru->DefinePolygon(8,x,y);
 
 1588    xtru->DefineSection(0,-40, -20., 10., 1.5);
 
 1589    xtru->DefineSection(1, 10, 0., 0., 0.5);
 
 1590    xtru->DefineSection(2, 10, 0., 0., 0.7);
 
 1591    xtru->DefineSection(3, 40, 10., 20., 0.9);
 
 1592    vol->SetLineColor(randomColor());
 
 1593    vol->SetLineWidth(2);
 
 1594    top->AddNode(vol,1);
 
 1595    gGeoManager->CloseGeometry();
 
 1596    gGeoManager->SetNsegments(80);
 
 1599    if (!comments) 
return;
 
 1601    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1602    pt->SetLineColor(1);
 
 1603    TText *text = pt->AddText(
"TGeoXtru - Polygonal extrusion class");
 
 1604    text->SetTextColor(2);
 
 1605    AddText(pt,
"fNvert",xtru->GetNvert(),
"number of polygone vertices");
 
 1606    AddText(pt,
"fNz",xtru->GetNz(),
"number of Z sections");
 
 1607    pt->AddText(
"----- Any Z section is an arbitrary polygone");
 
 1608    pt->AddText(
"----- The shape can have an arbitrary number of Z sections, as for pcon/pgon");
 
 1609    pt->AddText(
"----- Create with:    TGeoXtru *xtru = new TGeoXtru(nz);");
 
 1610    pt->AddText(
"----- Define the blueprint polygon :");
 
 1611    pt->AddText(
"-----                 Double_t x[8] = {-30,-30,30,30,15,15,-15,-15};");
 
 1612    pt->AddText(
"-----                 Double_t y[8] = {-30,30,30,-30,-30,15,15,-30};");
 
 1613    pt->AddText(
"-----                 xtru->DefinePolygon(8,x,y);");
 
 1614    pt->AddText(
"----- Define translations/scales of the blueprint for Z sections :");
 
 1615    pt->AddText(
"-----                 xtru->DefineSection(i, Zsection, x0, y0, scale);");
 
 1616    pt->AddText(
"----- Sections have to be defined in increasing Z order");
 
 1617    pt->AddText(
"----- 2 sections can be defined at same Z (not for first/last sections)");
 
 1619    pt->SetAllWith(
"-----",
"color",2);
 
 1620    pt->SetAllWith(
"-----",
"font",72);
 
 1621    pt->SetAllWith(
"-----",
"size",0.04);
 
 1622    pt->SetTextAlign(12);
 
 1623    pt->SetTextSize(0.044);
 
 1631    gROOT->GetListOfCanvases()->Delete();
 
 1632    TCanvas *c = 
new TCanvas(
"composite shape", 
"A Boolean shape composition", 700,1000);
 
 1636       gPad->SetPad(0,0,1,0.4);
 
 1638       gPad->SetPad(0,0.4,1,1);
 
 1640    if (gGeoManager) 
delete gGeoManager;
 
 1641    new TGeoManager(
"xtru", 
"poza12");
 
 1642    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1643    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1644    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,100);
 
 1645    gGeoManager->SetTopVolume(top);
 
 1648    TGeoPgon *pgon = 
new TGeoPgon(
"pg",0.,360.,6,2);
 
 1649    pgon->DefineSection(0,0,0,20);
 
 1650    pgon->DefineSection(1, 30,0,20);
 
 1652    new TGeoSphere(
"sph", 40., 45.);
 
 1654    TGeoTranslation *tr = 
new TGeoTranslation(0., 0., 45.);
 
 1657    tr->RegisterYourself();
 
 1659    TGeoCompositeShape *cs = 
new TGeoCompositeShape(
"mir", 
"sph:tr*pg");
 
 1661    TGeoVolume *vol = 
new TGeoVolume(
"COMP",cs);
 
 1662    vol->SetLineColor(randomColor());
 
 1663    top->AddNode(vol,1);
 
 1664    gGeoManager->CloseGeometry();
 
 1665    gGeoManager->SetNsegments(100);
 
 1668    if (!comments) 
return;
 
 1670    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1671    pt->SetLineColor(1);
 
 1672    TText *text = pt->AddText(
"TGeoCompositeShape - composite shape class");
 
 1673    text->SetTextColor(2);
 
 1674    pt->AddText(
"----- Define the shape components and don't forget to name them");
 
 1675    pt->AddText(
"----- Define geometrical transformations that apply to shape components");
 
 1676    pt->AddText(
"----- Name all transformations and register them");
 
 1677    pt->AddText(
"----- Define the composite shape based on a Boolean expression");
 
 1678    pt->AddText(
"                TGeoCompositeShape(\"someName\", \"expression\")");
 
 1679    pt->AddText(
"----- Expression is made of <shapeName:transfName> components related by Boolean operators");
 
 1680    pt->AddText(
"----- Boolean operators can be: (+) union, (-) subtraction and (*) intersection");
 
 1681    pt->AddText(
"----- Use parenthesis in the expression to force precedence");
 
 1683    pt->SetAllWith(
"-----",
"color",4);
 
 1684    pt->SetAllWith(
"-----",
"font",72);
 
 1685    pt->SetAllWith(
"-----",
"size",0.04);
 
 1686    pt->SetTextAlign(12);
 
 1687    pt->SetTextSize(0.044);
 
 1727    gROOT->GetListOfCanvases()->Delete();
 
 1728    TCanvas *c = 
new TCanvas(
"composite shape", 
"A Boolean shape composition", 700,1000);
 
 1732       gPad->SetPad(0,0,1,0.4);
 
 1734       gPad->SetPad(0,0.4,1,1);
 
 1736    if (gGeoManager) 
delete gGeoManager;
 
 1737    new TGeoManager(
"alignment", 
"Ideal geometry");
 
 1738    TGeoMaterial *mat = 
new TGeoMaterial(
"Al", 26.98,13,2.7);
 
 1739    TGeoMedium *med = 
new TGeoMedium(
"MED",1,mat);
 
 1740    TGeoVolume *top = gGeoManager->MakeBox(
"TOP",med,100,100,10);
 
 1741    gGeoManager->SetTopVolume(top);
 
 1742    TGeoVolume *slicex = top->Divide(
"SX",1,10,-100,10);
 
 1743    TGeoVolume *slicey = slicex->Divide(
"SY",2,10,-100,10);
 
 1744    TGeoVolume *vol = gGeoManager->MakePgon(
"CELL",med,0.,360.,6,2);
 
 1745    TGeoPgon *pgon = (TGeoPgon*)(vol->GetShape());
 
 1746    pgon->DefineSection(0,-5,0.,2.);
 
 1747    pgon->DefineSection(1,5,0.,2.);
 
 1748    vol->SetLineColor(randomColor());
 
 1749    slicey->AddNode(vol,1);
 
 1750    gGeoManager->CloseGeometry();
 
 1751    gGeoManager->SetNsegments(80);
 
 1754    if (!comments) 
return;
 
 1756    TPaveText *pt = 
new TPaveText(0.01,0.01,0.99,0.99);
 
 1757    pt->SetLineColor(1);
 
 1758    TText *text = pt->AddText(
"Ideal / Aligned geometry");
 
 1759    text->SetTextColor(2);
 
 1760    pt->AddText(
"-- Create physical nodes for the objects you want to align");
 
 1761    pt->AddText(
"-- You must start from a valid CLOSED geometry");
 
 1762    pt->AddText(
"    TGeoPhysicalNode *node = gGeoManager->MakePhysicalNode(const char *path)");
 
 1763    pt->AddText(
"    + creates a physical node represented by path, e.g. TOP_1/A_2/B_3");
 
 1764    pt->AddText(
"    node->Align(TGeoMatrix *newmat, TGeoShape *newshape, Bool_t check=kFALSE)");
 
 1765    pt->AddText(
"    + newmat = new matrix to replace final node LOCAL matrix");
 
 1766    pt->AddText(
"    + newshape = new shape to replace final node shape");
 
 1767    pt->AddText(
"    + check = optional check if the new aligned node is overlapping");
 
 1769    pt->SetAllWith(
"--",
"color",4);
 
 1770    pt->SetAllWith(
"--",
"font",72);
 
 1771    pt->SetAllWith(
"--",
"size",0.04);
 
 1772    pt->SetAllWith(
"+",
"color",2);
 
 1773    pt->SetAllWith(
"+",
"font",72);
 
 1774    pt->SetAllWith(
"+",
"size",0.04);
 
 1775    pt->SetTextAlign(12);
 
 1776    pt->SetTextSize(0.044);
 
 1784    if (!gGeoManager) 
return;
 
 1785    if (strcmp(gGeoManager->GetName(),
"alignment")) {
 
 1786       printf(
"Click: <Ideal geometry> first\n");
 
 1790    TObjArray *list = gGeoManager->GetListOfPhysicalNodes();
 
 1791    TGeoPhysicalNode *node;
 
 1792    TGeoTranslation *tr;
 
 1793    for (Int_t i=1; i<=10; i++) {
 
 1794       for (Int_t j=1; j<=10; j++) {
 
 1796          sprintf(name, 
"TOP_1/SX_%d/SY_%d/CELL_1",i,j);
 
 1797          if (list) node = (TGeoPhysicalNode*)list->At(10*(i-1)+j-1);
 
 1798          if (!node) node = gGeoManager->MakePhysicalNode(name);
 
 1799          if (node->IsAligned()) {
 
 1800             tr = (TGeoTranslation*)node->GetNode()->GetMatrix();
 
 1801             tr->SetTranslation(2.*gRandom->Rndm(), 2.*gRandom->Rndm(),0.);
 
 1803             tr = 
new TGeoTranslation(2.*gRandom->Rndm(), 2.*gRandom->Rndm(),0.);