GUI to draw the geometry shapes.
void autorotate();
void MakePicture()
{
if (view) {
}
if (is_raytracing != raytracing) {
}
}
void AddText(
TPaveText *pave,
const char *datamember,
Double_t value,
const char *comment)
{
char line[128];
for (
Int_t i=0; i<128; i++) line[i] =
' ';
memcpy(&line[0], datamember, strlen(datamember));
line[10] = '=';
char number[20];
sprintf(number, "%5.2f", value);
memcpy(&line[12], number, strlen(number));
line[26] = '=';
line[27] = '>';
sprintf(&line[30], "%s",comment);
}
void AddText(
TPaveText *pave,
const char *datamember,
Int_t value,
const char *comment)
{
char line[128];
for (
Int_t i=0; i<128; i++) line[i] =
' ';
memcpy(&line[0], datamember, strlen(datamember));
line[10] = '=';
char number[20];
sprintf(number, "%5i", value);
memcpy(&line[12], number, strlen(number));
line[26] = '=';
line[27] = '>';
sprintf(&line[30], "%s",comment);
}
{
char line[128];
if (!pave || !pf) return;
for (
Int_t i=0; i<128; i++) line[i] =
' ';
sprintf(line,
"Division of %s on axis %d (%s)", volume->
GetName(), iaxis,sh->
GetAxisName(iaxis));
text->SetTextAlign(12);
AddText(pave,
"fNdiv",finder->
GetNdiv(),
"number of divisions");
AddText(pave,
"fStart",finder->
GetStart(),
"start divisioning position");
AddText(pave,
"fStep",finder->
GetStep(),
"division step");
}
{
if (!c || !vol) return;
char fname[32];
switch (iaxis) {
case 0:
sprintf(fname,"t_%s.gif",name);
break;
default:
}
}
{
}
void raytrace() {
raytracing = !raytracing;
if (!painter) return;
}
void help() {
new TCanvas(
"chelp",
"Help to run demos",200,10,700,600);
welcome->
AddText(
"Welcome to the new geometry package");
hdemo->
AddText(
"- Demo for building TGeo basic shapes and simple geometry. Shape parameters are");
hdemo->
AddText(
" displayed in the right pad");
hdemo->
AddText(
"- Click left mouse button to execute one demo");
hdemo->
AddText(
"- While pointing the mouse to the pad containing the geometry, do:");
hdemo->
AddText(
"- .... click-and-move to rotate");
hdemo->
AddText(
"- .... press j/k to zoom/unzoom");
hdemo->
AddText(
"- .... press l/h/u/i to move the view center around");
hdemo->
AddText(
"- Click Ray-trace ON/OFF to toggle ray-tracing");
hdemo->
AddText(
"- Use <View with x3d> from the <View> menu to get an x3d view");
hdemo->
AddText(
"- .... same methods to rotate/zoom/move the view");
hdemo->
AddText(
"- Execute box(1,8) to divide a box in 8 equal slices along X");
hdemo->
AddText(
"- Most shapes can be divided on X,Y,Z,Rxy or Phi :");
hdemo->
AddText(
"- .... root[0] <shape>(IAXIS, NDIV, START, STEP);");
hdemo->
AddText(
" .... IAXIS = 1,2,3 meaning (X,Y,Z) or (Rxy, Phi, Z)");
hdemo->
AddText(
" .... NDIV = number of slices");
hdemo->
AddText(
" .... START = start slicing position");
hdemo->
AddText(
" .... STEP = division step");
hdemo->
AddText(
"- Click Comments ON/OFF to toggle comments");
hdemo->
AddText(
"- Click Ideal/Align geometry to see how alignment works");
}
void geodemo ()
{
bar->
AddButton(
"How to run ",
"help()",
"Instructions for running this macro");
bar->
AddButton(
"Arb8 ",
"arb8()",
"An arbitrary polyhedron defined by vertices (max 8) sitting on 2 parallel planes");
bar->
AddButton(
"Box ",
"box()",
"A box shape.");
bar->
AddButton(
"Composite ",
"composite()",
"A composite shape");
bar->
AddButton(
"Cone ",
"cone()",
"A conical tube");
bar->
AddButton(
"Cone segment",
"coneseg()",
"A conical segment");
bar->
AddButton(
"Cut tube ",
"ctub()",
"A cut tube segment");
bar->
AddButton(
"Elliptical tube",
"eltu()",
"An elliptical tube");
bar->
AddButton(
"Extruded poly",
"xtru()",
"A general polygone extrusion");
bar->
AddButton(
"Hyperboloid ",
"hype()",
"A hyperboloid");
bar->
AddButton(
"Paraboloid ",
"parab()",
"A paraboloid");
bar->
AddButton(
"Polycone ",
"pcon()",
"A polycone shape");
bar->
AddButton(
"Polygone ",
"pgon()",
"A polygone");
bar->
AddButton(
"Parallelepiped",
"para()",
"A parallelepiped shape");
bar->
AddButton(
"Sphere ",
"sphere()",
"A spherical sector");
bar->
AddButton(
"Trd1 ",
"trd1()",
"A trapezoid with dX varying with Z");
bar->
AddButton(
"Trd2 ",
"trd2()",
"A trapezoid with both dX and dY varying with Z");
bar->
AddButton(
"Trapezoid ",
"trap()",
"A general trapezoid");
bar->
AddButton(
"Torus ",
"torus()",
"A toroidal segment");
bar->
AddButton(
"Tube ",
"tube()",
"A tube with inner and outer radius");
bar->
AddButton(
"Tube segment",
"tubeseg()",
"A tube segment");
bar->
AddButton(
"Twisted trap",
"gtra()",
"A twisted trapezoid");
bar->
AddButton(
"Aligned (ideal)",
"ideal()",
"An ideal (un-aligned) geometry");
bar->
AddButton(
"Un-aligned",
"align()",
"Some alignment operation");
bar->
AddButton(
"RAY-TRACE ON/OFF",
"raytrace()",
"Toggle ray-tracing mode");
bar->
AddButton(
"COMMENTS ON/OFF",
"comments = !comments;",
"Toggle explanations pad ON/OFF");
bar->
AddButton(
"AXES ON/OFF",
"axes()",
"Toggle axes ON/OFF");
bar->
AddButton(
"AUTOROTATE ON/OFF",
"autorotate()",
"Toggle autorotation ON/OFF");
}
void autorotate()
{
grotate = !grotate;
if (!grotate) {
return;
}
if (!view) return;
if (!painter) return;
while (grotate) {
if (
gROOT->IsInterrupted())
break;
longit += dphi;
if (longit>360) longit -= 360.;
return;
}
if (!view) {
return;
}
}
}
void axes()
{
axis = !axis;
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis<0 || iaxis>3) {
printf("Wrong division axis. Range is 1-3.\n");
return;
}
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fDX",box->
GetDX(),
"half length in X");
AddText(pt,
"fDY",box->
GetDY(),
"half length in Y");
AddText(pt,
"fDZ",box->
GetDZ(),
"half length in Z");
AddText(pt,
"fOrigin[0]",(box->
GetOrigin())[0],
"box origin on X");
AddText(pt,
"fOrigin[1]",(box->
GetOrigin())[1],
"box origin on Y");
AddText(pt,
"fOrigin[2]",(box->
GetOrigin())[2],
"box origin on Z");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: box(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be 1, 2 or 3 (X, Y, Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
TText *text = pt->
AddText(
"TGeoPara - parallelepiped class");
AddText(pt,
"fX",para->
GetX(),
"half length in X");
AddText(pt,
"fY",para->
GetY(),
"half length in Y");
AddText(pt,
"fZ",para->
GetZ(),
"half length in Z");
AddText(pt,
"fAlpha",para->
GetAlpha(),
"angle about Y of the Z bases");
AddText(pt,
"fTheta",para->
GetTheta(),
"inclination of para axis about Z");
AddText(pt,
"fPhi",para->
GetPhi(),
"phi angle of para axis");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: para(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be 1, 2 or 3 (X, Y, Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis<0 || iaxis>3) {
printf("Wrong division axis. Range is 1-3.\n");
return;
}
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fRmin",tube->
GetRmin(),
"minimum radius");
AddText(pt,
"fRmax",tube->
GetRmax(),
"maximum radius");
AddText(pt,
"fDZ", tube->
GetDZ(),
"half length in Z");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: tube(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be 1, 2 or 3 (Rxy, Phi, Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis<0 || iaxis>3) {
printf("Wrong division axis. Range is 1-3.\n");
return;
}
TCanvas *c =
new TCanvas(
"tubeseg shape",
"A tube segment ", 700,1000);
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
TText *text = pt->
AddText(
"TGeoTubeSeg - tube segment class");
AddText(pt,
"fRmin",tubeseg->
GetRmin(),
"minimum radius");
AddText(pt,
"fRmax",tubeseg->
GetRmax(),
"maximum radius");
AddText(pt,
"fDZ", tubeseg->
GetDZ(),
"half length in Z");
AddText(pt,
"fPhi1",tubeseg->
GetPhi1(),
"first phi limit");
AddText(pt,
"fPhi2",tubeseg->
GetPhi2(),
"second phi limit");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: tubeseg(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be 1, 2 or 3 (Rxy, Phi, Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis<0 || iaxis>2) {
printf("Wrong division axis. Range is 1-2.\n");
return;
}
TCanvas *c =
new TCanvas(
"ctub shape",
"A cut tube segment ", 700,1000);
if (comments) {
}
TGeoVolume *vol =
gGeoManager->
MakeCtub(
"CTUB",med, 20,30,40,-30,250, nlow[0], nlow[1], nlow[2], nhi[0],nhi[1],nhi[2]);
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
TText *text = pt->
AddText(
"TGeoTubeSeg - tube segment class");
AddText(pt,
"fRmin",tubeseg->
GetRmin(),
"minimum radius");
AddText(pt,
"fRmax",tubeseg->
GetRmax(),
"maximum radius");
AddText(pt,
"fDZ", tubeseg->
GetDZ(),
"half length in Z");
AddText(pt,
"fPhi1",tubeseg->
GetPhi1(),
"first phi limit");
AddText(pt,
"fPhi2",tubeseg->
GetPhi2(),
"second phi limit");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis<0 || iaxis>3) {
printf("Wrong division axis. Range is 1-3.\n");
return;
}
if (iaxis==1) {
printf("cannot divide cone on Rxy\n");
return;
}
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fDZ", cone->
GetDZ(),
"half length in Z");
AddText(pt,
"fRmin1",cone->
GetRmin1(),
"inner radius at -dz");
AddText(pt,
"fRmax1",cone->
GetRmax1(),
"outer radius at -dz");
AddText(pt,
"fRmin2",cone->
GetRmin2(),
"inner radius at +dz");
AddText(pt,
"fRmax2",cone->
GetRmax2(),
"outer radius at +dz");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: cone(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be 2 or 3 (Phi, Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis<0 || iaxis>3) {
printf("Wrong division axis. Range is 1-3.\n");
return;
}
TCanvas *c =
new TCanvas(
"coneseg shape",
"A cone segment", 700,1000);
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fDZ", coneseg->
GetDZ(),
"half length in Z");
AddText(pt,
"fRmin1",coneseg->
GetRmin1(),
"inner radius at -dz");
AddText(pt,
"fRmax1",coneseg->
GetRmax1(),
"outer radius at -dz");
AddText(pt,
"fRmin2",coneseg->
GetRmin1(),
"inner radius at +dz");
AddText(pt,
"fRmax2",coneseg->
GetRmax1(),
"outer radius at +dz");
AddText(pt,
"fPhi1",coneseg->
GetPhi1(),
"first phi limit");
AddText(pt,
"fPhi2",coneseg->
GetPhi2(),
"second phi limit");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: coneseg(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be 2 or 3 (Phi, Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c =
new TCanvas(
"eltu shape",
"An Elliptical tube", 700,1000);
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fA",eltu->
GetA(),
"semi-axis along x");
AddText(pt,
"fB",eltu->
GetB(),
"semi-axis along y");
AddText(pt,
"fDZ", eltu->
GetDZ(),
"half length in Z");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: eltu(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be 2 or 3 (Phi, Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis!=0) {
printf("Cannot divide spheres\n");
return;
}
TCanvas *c =
new TCanvas(
"Sphere shap",
"A spherical sector", 700,1000);
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fRmin",sphere->
GetRmin(),
"inner radius");
AddText(pt,
"fRmax",sphere->
GetRmax(),
"outer radius");
AddText(pt,
"fTheta1",sphere->
GetTheta1(),
"lower theta limit");
AddText(pt,
"fTheta2",sphere->
GetTheta2(),
"higher theta limit");
AddText(pt,
"fPhi1",sphere->
GetPhi1(),
"lower phi limit");
AddText(pt,
"fPhi2",sphere->
GetPhi2(),
"higher phi limit");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis!=0) {
printf("Cannot divide a torus\n");
return;
}
TCanvas *c =
new TCanvas(
"torus shape",
"A toroidal segment", 700,1000);
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fR",tor->
GetR(),
"radius of the ring");
AddText(pt,
"fRmin",tor->
GetRmin(),
"minimum radius");
AddText(pt,
"fRmax",tor->
GetRmax(),
"maximum radius");
AddText(pt,
"fPhi1", tor->
GetPhi1(),
"starting phi angle");
AddText(pt,
"fDphi", tor->
GetDphi(),
"phi range");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis<0 || iaxis>3) {
printf("Wrong division axis. Range is 1-3.\n");
return;
}
if (iaxis==1) {
printf("Cannot divide trd1 on X axis\n");
return;
}
TCanvas *c =
new TCanvas(
"trd1 shape",
"A trapezoid with dX varying", 700,1000);
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fDx1",trd1->
GetDx1(),
"half length in X at lower Z surface(-dz)");
AddText(pt,
"fDx2",trd1->
GetDx2(),
"half length in X at higher Z surface(+dz)");
AddText(pt,
"fDy",trd1->
GetDy(),
"half length in Y");
AddText(pt,
"fDz",trd1->
GetDz(),
"half length in Z");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: trd1(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be 2 or 3 (Y, Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
void parab()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c =
new TCanvas(
"parab shape",
"A paraboloid segment", 700,1000);
if (comments) {
}
MakePicture();
if (!comments) return;
TText *text = pt->
AddText(
"TGeoParaboloid - Paraboloid class");
AddText(pt,
"fRlo",par->
GetRlo(),
"radius at Z=-dz");
AddText(pt,
"fRhi",par->
GetRhi(),
"radius at Z=+dz");
AddText(pt,
"fDz",par->
GetDz(),
"half-length on Z axis");
pt->
AddText(
"----- A paraboloid is described by the equation:");
pt->
AddText(
"----- z = a*r*r + b; where: r = x*x + y*y");
pt->
AddText(
"----- Create with: TGeoParaboloid *parab = new TGeoParaboloid(rlo, rhi, dz);");
pt->
AddText(
"----- dz: half-length in Z (range from -dz to +dz");
pt->
AddText(
"----- rlo: radius at z=-dz given by: -dz = a*rlo*rlo + b");
pt->
AddText(
"----- rhi: radius at z=+dz given by: dz = a*rhi*rhi + b");
pt->
AddText(
"----- rlo != rhi; both >= 0");
}
void hype()
{
gROOT->GetListOfCanvases()->Delete();
if (comments) {
}
MakePicture();
if (!comments) return;
AddText(pt,
"fRmin",hype->
GetRmin(),
"minimum inner radius");
AddText(pt,
"fStIn",hype->
GetStIn(),
"inner surface stereo angle [deg]");
AddText(pt,
"fRmax",hype->
GetRmax(),
"minimum outer radius");
AddText(pt,
"fStOut",hype->
GetStOut(),
"outer surface stereo angle [deg]");
AddText(pt,
"fDz",hype->
GetDz(),
"half-length on Z axis");
pt->
AddText(
"----- A hyperboloid is described by the equation:");
pt->
AddText(
"----- r^2 - (tan(stereo)*z)^2 = rmin^2; where: r = x*x + y*y");
pt->
AddText(
"----- Create with: TGeoHype *hype = new TGeoHype(rin, stin, rout, stout, dz);");
pt->
AddText(
"----- rin < rout; rout > 0");
pt->
AddText(
"----- rin = 0; stin > 0 => inner surface conical");
pt->
AddText(
"----- stin/stout = 0 => corresponding surface cylindrical");
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis<0 || iaxis>3) {
printf("Wrong division axis. Range is 1-3.\n");
return;
}
if (iaxis==1) {
printf("Cannot divide pcon on Rxy\n");
return;
}
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fPhi1",pcon->
GetPhi1(),
"lower phi limit");
AddText(pt,
"fDphi",pcon->
GetDphi(),
"phi range");
AddText(pt,
"fNz",pcon->
GetNz(),
"number of z planes");
char line[128];
sprintf(line, "fZ[%i]=%5.2f fRmin[%i]=%5.2f fRmax[%i]=%5.2f",
text->SetTextAlign(12);
}
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: pcon(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be 2 or 3 (Phi, Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis<0 || iaxis>3) {
printf("Wrong division axis. Range is 1-3.\n");
return;
}
if (iaxis==1) {
printf("Cannot divide pgon on Rxy\n");
return;
}
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fPhi1",pgon->
GetPhi1(),
"lower phi limit");
AddText(pt,
"fDphi",pgon->
GetDphi(),
"phi range");
AddText(pt,
"fNedges",pgon->
GetNedges(),
"number of edges");
AddText(pt,
"fNz",pgon->
GetNz(),
"number of z planes");
char line[128];
sprintf(line, "fZ[%i]=%5.2f fRmin[%i]=%5.2f fRmax[%i]=%5.2f",
text->SetTextAlign(12);
}
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: pgon(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be 2 or 3 (Phi, Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis!=0) {
printf("Cannot divide arb8\n");
return;
}
TCanvas *c =
new TCanvas(
"arb8 shape",
"An arbitrary polyhedron", 700,1000);
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fDz",arb->
GetDz(),
"Z half length");
char line[128];
text = pt->
AddText(
"Vertices on lower Z plane:");
for (i=0; i<4; i++) {
sprintf(line," fXY[%d] = (%5.2f, %5.2f)", i, vert[2*i], vert[2*i+1]);
}
text = pt->
AddText(
"Vertices on higher Z plane:");
for (i=4; i<8; i++) {
sprintf(line," fXY[%d] = (%5.2f, %5.2f)", i, vert[2*i], vert[2*i+1]);
}
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis && iaxis!=3) {
printf("Wrong division axis. Can divide only in Z (3)\n");
return;
}
TCanvas *c =
new TCanvas(
"trd2 shape",
"A trapezoid with dX and dY varying with Z", 700,1000);
if (comments) {
}
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fDx1",trd2->
GetDx1(),
"half length in X at lower Z surface(-dz)");
AddText(pt,
"fDx2",trd2->
GetDx2(),
"half length in X at higher Z surface(+dz)");
AddText(pt,
"fDy1",trd2->
GetDy1(),
"half length in Y at lower Z surface(-dz)");
AddText(pt,
"fDy2",trd2->
GetDy2(),
"half length in Y at higher Z surface(-dz)");
AddText(pt,
"fDz",trd2->
GetDz(),
"half length in Z");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: trd2(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be only 3 (Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis && iaxis!=3) {
printf("Wrong division axis. Can divide only in Z (3)\n");
return;
}
TCanvas *c =
new TCanvas(
"trap shape",
"A more general trapezoid", 700,1000);
if (comments) {
}
TGeoVolume *vol =
gGeoManager->
MakeTrap(
"Trap",med, 30,15,30,20,10,15,0,20,10,15,0);
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
AddText(pt,
"fDz",trap->
GetDz(),
"half length in Z");
AddText(pt,
"fTheta",trap->
GetTheta(),
"theta angle of trapezoid axis");
AddText(pt,
"fPhi",trap->
GetPhi(),
"phi angle of trapezoid axis");
AddText(pt,
"fH1",trap->
GetH1(),
"half length in y at -fDz");
AddText(pt,
"fAlpha1",trap->
GetAlpha1(),
"angle between centers of x edges and y axis at -fDz");
AddText(pt,
"fBl1",trap->
GetBl1(),
"half length in x at -dZ and y=-fH1");
AddText(pt,
"fTl1",trap->
GetTl1(),
"half length in x at -dZ and y=+fH1");
AddText(pt,
"fH2",trap->
GetH2(),
"half length in y at +fDz");
AddText(pt,
"fBl2",trap->
GetBl2(),
"half length in x at +dZ and y=-fH1");
AddText(pt,
"fTl2",trap->
GetTl2(),
"half length in x at +dZ and y=+fH1");
AddText(pt,
"fAlpha2",trap->
GetAlpha2(),
"angle between centers of x edges and y axis at +fDz");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: trap(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be only 3 (Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
{
gROOT->GetListOfCanvases()->Delete();
if (iaxis && iaxis!=3) {
printf("Wrong division axis. Can divide only in Z (3)\n");
return;
}
TCanvas *c =
new TCanvas(
"gtra shape",
"A twisted trapezoid", 700,1000);
if (comments) {
}
TGeoVolume *vol =
gGeoManager->
MakeGtra(
"Gtra",med, 30,15,30,30,20,10,15,0,20,10,15,0);
if (iaxis) {
if (!slice) return;
}
MakePicture();
if (!comments) return;
TText *text = pt->
AddText(
"TGeoGtra - Twisted trapezoid class");
AddText(pt,
"fDz",trap->
GetDz(),
"half length in Z");
AddText(pt,
"fTheta",trap->
GetTheta(),
"theta angle of trapezoid axis");
AddText(pt,
"fPhi",trap->
GetPhi(),
"phi angle of trapezoid axis");
AddText(pt,
"fH1",trap->
GetH1(),
"half length in y at -fDz");
AddText(pt,
"fAlpha1",trap->
GetAlpha1(),
"angle between centers of x edges and y axis at -fDz");
AddText(pt,
"fBl1",trap->
GetBl1(),
"half length in x at -dZ and y=-fH1");
AddText(pt,
"fTl1",trap->
GetTl1(),
"half length in x at -dZ and y=+fH1");
AddText(pt,
"fH2",trap->
GetH2(),
"half length in y at +fDz");
AddText(pt,
"fBl2",trap->
GetBl2(),
"half length in x at +dZ and y=-fH1");
AddText(pt,
"fTl2",trap->
GetTl2(),
"half length in x at +dZ and y=+fH1");
AddText(pt,
"fAlpha2",trap->
GetAlpha2(),
"angle between centers of x edges and y axis at +fDz");
if (iaxis) AddText(pt, vol->
GetFinder(), iaxis);
pt->
AddText(
"Execute: gtra(iaxis, ndiv, start, step) to divide this.");
pt->
AddText(
"----- IAXIS can be only 3 (Z)");
pt->
AddText(
"----- NDIV must be a positive integer");
pt->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pt->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pt->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
void xtru()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c =
new TCanvas(
"gtra shape",
"A twisted trapezoid", 700,1000);
if (comments) {
}
Double_t x[8] = {-30,-30,30,30,15,15,-15,-15};
Double_t y[8] = {-30,30,30,-30,-30,15,15,-30};
MakePicture();
if (!comments) return;
TText *text = pt->
AddText(
"TGeoXtru - Polygonal extrusion class");
AddText(pt,
"fNvert",xtru->
GetNvert(),
"number of polygone vertices");
AddText(pt,
"fNz",xtru->
GetNz(),
"number of Z sections");
pt->
AddText(
"----- Any Z section is an arbitrary polygone");
pt->
AddText(
"----- The shape can have an arbitrary number of Z sections, as for pcon/pgon");
pt->
AddText(
"----- Create with: TGeoXtru *xtru = new TGeoXtru(nz);");
pt->
AddText(
"----- Define the blueprint polygon :");
pt->
AddText(
"----- Double_t x[8] = {-30,-30,30,30,15,15,-15,-15};");
pt->
AddText(
"----- Double_t y[8] = {-30,30,30,-30,-30,15,15,-30};");
pt->
AddText(
"----- xtru->DefinePolygon(8,x,y);");
pt->
AddText(
"----- Define translations/scales of the blueprint for Z sections :");
pt->
AddText(
"----- xtru->DefineSection(i, Zsection, x0, y0, scale);");
pt->
AddText(
"----- Sections have to be defined in increasing Z order");
pt->
AddText(
"----- 2 sections can be defined at same Z (not for first/last sections)");
}
void composite()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c =
new TCanvas(
"composite shape",
"A Boolean shape composition", 700,1000);
if (comments) {
}
MakePicture();
if (!comments) return;
TText *text = pt->
AddText(
"TGeoCompositeShape - composite shape class");
pt->
AddText(
"----- Define the shape components and don't forget to name them");
pt->
AddText(
"----- Define geometrical transformations that apply to shape components");
pt->
AddText(
"----- Name all transformations and register them");
pt->
AddText(
"----- Define the composite shape based on a Boolean expression");
pt->
AddText(
" TGeoCompositeShape(\"someName\", \"expression\")");
pt->
AddText(
"----- Expression is made of <shapeName:transfName> components related by Boolean operators");
pt->
AddText(
"----- Boolean operators can be: (+) union, (-) subtraction and (*) intersection");
pt->
AddText(
"----- Use parenthesis in the expression to force precedence");
}
void ideal()
{
gROOT->GetListOfCanvases()->Delete();
TCanvas *c =
new TCanvas(
"composite shape",
"A Boolean shape composition", 700,1000);
if (comments) {
}
MakePicture();
if (!comments) return;
pt->
AddText(
"-- Create physical nodes for the objects you want to align");
pt->
AddText(
"-- You must start from a valid CLOSED geometry");
pt->
AddText(
" TGeoPhysicalNode *node = gGeoManager->MakePhysicalNode(const char *path)");
pt->
AddText(
" + creates a physical node represented by path, e.g. TOP_1/A_2/B_3");
pt->
AddText(
" node->Align(TGeoMatrix *newmat, TGeoShape *newshape, Bool_t check=kFALSE)");
pt->
AddText(
" + newmat = new matrix to replace final node LOCAL matrix");
pt->
AddText(
" + newshape = new shape to replace final node shape");
pt->
AddText(
" + check = optional check if the new aligned node is overlapping");
}
void align()
{
printf("Click: <Ideal geometry> first\n");
return;
}
char name[30];
for (
Int_t i=1; i<=10; i++) {
for (
Int_t j=1; j<=10; j++) {
node = 0;
sprintf(name, "TOP_1/SX_%d/SY_%d/CELL_1",i,j);
} else {
}
}
}
}
}