GUI to draw the geometry shapes.
void MakePicture()
{
if (view) {
if (axis)
}
if (is_raytracing != raytracing) {
gGeoManager->GetTopVolume()->SetVisRaytrace(raytracing);
}
}
void AddMemberInfo(
TPaveText *pave,
const char *datamember,
Double_t value,
const char *comment)
{
while (
line.Length() < 10)
}
void AddMemberInfo(
TPaveText *pave,
const char *datamember,
Int_t value,
const char *comment)
{
while (
line.Length() < 10)
}
{
if (!pave || !pf || !iaxis)
return;
AddMemberInfo(pave,
"fNdiv", finder->
GetNdiv(),
"number of divisions");
AddMemberInfo(pave,
"fStart", finder->
GetStart(),
"start divisioning position");
AddMemberInfo(pave,
"fStep", finder->
GetStep(),
"division step");
}
void AddExecInfo(
TPaveText *pave,
const char *
name =
nullptr,
const char *axisinfo =
nullptr)
{
pave->
AddText(
"----- NDIV must be a positive integer");
pave->
AddText(
"----- START must be a valid axis offset within shape range on divided axis");
pave->
AddText(
"----- STEP is the division step. START+NDIV*STEP must be in range also");
pave->
AddText(
"----- If START and STEP are omitted, all range of the axis will be divided");
}
}
{
return;
if (iaxis == 0)
else if (step == 0)
else
}
{
return (1 +
Int_t(color));
}
void raytrace()
{
raytracing = !raytracing;
bool drawn =
gPad->GetListOfPrimitives()->FindObject(top);
if (drawn)
top->SetVisRaytrace(raytracing);
}
}
void help()
{
auto c = (
TCanvas *)
gROOT->GetListOfCanvases()->FindObject(
"geom_help");
} else {
c =
new TCanvas(
"geom_help",
"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>/<View With>/<OpenGL> for an external 3D view");
hdemo->
AddText(
"- .... use the OpenGL viewer controls 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 autorotate()
{
grotate = !grotate;
if (!grotate) {
return;
}
return;
if (!view)
return;
return;
if (!painter)
return;
while (grotate) {
break;
if (
gROOT->IsInterrupted())
break;
longit += dphi;
if (longit > 360)
longit -= 360.;
return;
}
if (!view) {
return;
}
}
delete timer;
}
void axes()
{
axis = !axis;
if (view)
}
TCanvas *create_canvas(
const char *title)
{
auto c = (
TCanvas *)
gROOT->GetListOfCanvases()->FindObject(
"geom_draw");
} else {
c =
new TCanvas(
"geom_draw", title, 700, 1000);
}
if (comments) {
c->GetPad(2)->SetPad(0, 0, 1, 0.4);
c->GetPad(1)->SetPad(0, 0.4, 1, 1);
}
}
{
auto c = create_canvas(
"A simple box");
if ((iaxis > 0) && (iaxis < 4)) {
if (!slice)
return;
}
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fDX",
box->GetDX(),
"half length in X");
AddMemberInfo(
pt,
"fDY",
box->GetDY(),
"half length in Y");
AddMemberInfo(
pt,
"fDZ",
box->GetDZ(),
"half length in Z");
AddMemberInfo(
pt,
"fOrigin[0]", (
box->GetOrigin())[0],
"box origin on X");
AddMemberInfo(
pt,
"fOrigin[1]", (
box->GetOrigin())[1],
"box origin on Y");
AddMemberInfo(
pt,
"fOrigin[2]", (
box->GetOrigin())[2],
"box origin on Z");
AddExecInfo(
pt,
"box",
"1, 2 or 3 (X, Y, Z)");
}
{
auto c = create_canvas(
"A parallelepiped");
if ((iaxis > 0) && (iaxis < 4)) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed range is 1-3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
TText *
text =
pt->AddText(
"TGeoPara - parallelepiped class");
AddMemberInfo(
pt,
"fX", para->
GetX(),
"half length in X");
AddMemberInfo(
pt,
"fY", para->
GetY(),
"half length in Y");
AddMemberInfo(
pt,
"fZ", para->
GetZ(),
"half length in Z");
AddMemberInfo(
pt,
"fAlpha", para->
GetAlpha(),
"angle about Y of the Z bases");
AddMemberInfo(
pt,
"fTheta", para->
GetTheta(),
"inclination of para axis about Z");
AddMemberInfo(
pt,
"fPhi", para->
GetPhi(),
"phi angle of para axis");
AddExecInfo(
pt,
"para",
"1, 2 or 3 (X, Y, Z)");
}
{
auto c = create_canvas(
"A tube");
if ((iaxis > 0) && (iaxis < 4)) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed range is 1-3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fRmin", tube->
GetRmin(),
"minimum radius");
AddMemberInfo(
pt,
"fRmax", tube->
GetRmax(),
"maximum radius");
AddMemberInfo(
pt,
"fDZ", tube->
GetDZ(),
"half length in Z");
AddExecInfo(
pt,
"tube",
"1, 2 or 3 (Rxy, Phi, Z)");
}
{
auto c = create_canvas(
"A tube segment");
if ((iaxis > 0) && (iaxis < 4)) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed range is 1-3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
TText *
text =
pt->AddText(
"TGeoTubeSeg - tube segment class");
AddMemberInfo(
pt,
"fRmin", tubeseg->
GetRmin(),
"minimum radius");
AddMemberInfo(
pt,
"fRmax", tubeseg->
GetRmax(),
"maximum radius");
AddMemberInfo(
pt,
"fDZ", tubeseg->
GetDZ(),
"half length in Z");
AddMemberInfo(
pt,
"fPhi1", tubeseg->
GetPhi1(),
"first phi limit");
AddMemberInfo(
pt,
"fPhi2", tubeseg->
GetPhi2(),
"second phi limit");
AddExecInfo(
pt,
"tubeseg",
"1, 2 or 3 (Rxy, Phi, Z)");
}
{
auto c = create_canvas(
"A cut tube segment");
gGeoManager->MakeCtub(
"CTUB", med, 20, 30, 40, -30, 250, nlow[0], nlow[1], nlow[2], nhi[0], nhi[1], nhi[2]);
if (iaxis == 1 || iaxis == 2) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed range is 1-2.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
TText *
text =
pt->AddText(
"TGeoTubeSeg - tube segment class");
AddMemberInfo(
pt,
"fRmin", tubeseg->
GetRmin(),
"minimum radius");
AddMemberInfo(
pt,
"fRmax", tubeseg->
GetRmax(),
"maximum radius");
AddMemberInfo(
pt,
"fDZ", tubeseg->
GetDZ(),
"half length in Z");
AddMemberInfo(
pt,
"fPhi1", tubeseg->
GetPhi1(),
"first phi limit");
AddMemberInfo(
pt,
"fPhi2", tubeseg->
GetPhi2(),
"second phi limit");
AddExecInfo(
pt,
"ctub",
"1 or 2");
}
{
auto c = create_canvas(
"A cone");
if (iaxis == 2 || iaxis == 3) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed range is 2-3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fDZ", cone->
GetDZ(),
"half length in Z");
AddMemberInfo(
pt,
"fRmin1", cone->
GetRmin1(),
"inner radius at -dz");
AddMemberInfo(
pt,
"fRmax1", cone->
GetRmax1(),
"outer radius at -dz");
AddMemberInfo(
pt,
"fRmin2", cone->
GetRmin2(),
"inner radius at +dz");
AddMemberInfo(
pt,
"fRmax2", cone->
GetRmax2(),
"outer radius at +dz");
AddExecInfo(
pt,
"cone",
"2 or 3 (Phi, Z)");
}
{
auto c = create_canvas(
"A cone segment");
if (iaxis >= 2 && iaxis <= 3) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed range is 2-3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
TText *
text =
pt->AddText(
"TGeoConeSeg - coneseg class");
AddMemberInfo(
pt,
"fDZ", coneseg->
GetDZ(),
"half length in Z");
AddMemberInfo(
pt,
"fRmin1", coneseg->
GetRmin1(),
"inner radius at -dz");
AddMemberInfo(
pt,
"fRmax1", coneseg->
GetRmax1(),
"outer radius at -dz");
AddMemberInfo(
pt,
"fRmin2", coneseg->
GetRmin1(),
"inner radius at +dz");
AddMemberInfo(
pt,
"fRmax2", coneseg->
GetRmax1(),
"outer radius at +dz");
AddMemberInfo(
pt,
"fPhi1", coneseg->
GetPhi1(),
"first phi limit");
AddMemberInfo(
pt,
"fPhi2", coneseg->
GetPhi2(),
"second phi limit");
AddExecInfo(
pt,
"coneseg",
"2 or 3 (Phi, Z)");
}
{
auto c = create_canvas(
"An Elliptical tube");
if (iaxis >= 2 && iaxis <= 3) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed range is 2-3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fA", eltu->
GetA(),
"semi-axis along x");
AddMemberInfo(
pt,
"fB", eltu->
GetB(),
"semi-axis along y");
AddMemberInfo(
pt,
"fDZ", eltu->
GetDZ(),
"half length in Z");
AddExecInfo(
pt,
"eltu",
"2 or 3 (Phi, Z)");
}
void sphere()
{
auto c = create_canvas(
"A spherical sector");
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fRmin", sphere->
GetRmin(),
"inner radius");
AddMemberInfo(
pt,
"fRmax", sphere->
GetRmax(),
"outer radius");
AddMemberInfo(
pt,
"fTheta1", sphere->
GetTheta1(),
"lower theta limit");
AddMemberInfo(
pt,
"fTheta2", sphere->
GetTheta2(),
"higher theta limit");
AddMemberInfo(
pt,
"fPhi1", sphere->
GetPhi1(),
"lower phi limit");
AddMemberInfo(
pt,
"fPhi2", sphere->
GetPhi2(),
"higher phi limit");
AddExecInfo(
pt,
"sphere");
}
void torus()
{
auto c = create_canvas(
"A toroidal segment");
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fR", tor->
GetR(),
"radius of the ring");
AddMemberInfo(
pt,
"fRmin", tor->
GetRmin(),
"minimum radius");
AddMemberInfo(
pt,
"fRmax", tor->
GetRmax(),
"maximum radius");
AddMemberInfo(
pt,
"fPhi1", tor->
GetPhi1(),
"starting phi angle");
AddMemberInfo(
pt,
"fDphi", tor->
GetDphi(),
"phi range");
AddExecInfo(
pt,
"torus");
}
{
auto c = create_canvas(
"A trapezoid with dX varying");
if (iaxis == 2 || iaxis == 3) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed range is 2-3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fDx1", trd1->
GetDx1(),
"half length in X at lower Z surface(-dz)");
AddMemberInfo(
pt,
"fDx2", trd1->
GetDx2(),
"half length in X at higher Z surface(+dz)");
AddMemberInfo(
pt,
"fDy", trd1->
GetDy(),
"half length in Y");
AddMemberInfo(
pt,
"fDz", trd1->
GetDz(),
"half length in Z");
AddExecInfo(
pt,
"trd1",
"2 or 3 (Y, Z)");
}
void parab()
{
auto c = create_canvas(
"A paraboloid segment");
MakePicture();
if (!comments)
return;
TText *
text =
pt->AddText(
"TGeoParaboloid - Paraboloid class");
AddMemberInfo(
pt,
"fRlo", par->
GetRlo(),
"radius at Z=-dz");
AddMemberInfo(
pt,
"fRhi", par->
GetRhi(),
"radius at Z=+dz");
AddMemberInfo(
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");
AddExecInfo(
pt,
"parab");
}
void hype()
{
auto c = create_canvas(
"A hyperboloid");
MakePicture();
if (!comments)
return;
TText *
text =
pt->AddText(
"TGeoHype - Hyperboloid class");
AddMemberInfo(
pt,
"fRmin", hype->
GetRmin(),
"minimum inner radius");
AddMemberInfo(
pt,
"fStIn", hype->
GetStIn(),
"inner surface stereo angle [deg]");
AddMemberInfo(
pt,
"fRmax", hype->
GetRmax(),
"minimum outer radius");
AddMemberInfo(
pt,
"fStOut", hype->
GetStOut(),
"outer surface stereo angle [deg]");
AddMemberInfo(
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");
}
{
auto c = create_canvas(
"A polycone");
if (iaxis == 2 || iaxis == 3) {
if (!slice)
return;
}
if (iaxis) {
printf("Wrong division axis %d. Allowed range is 2-3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fPhi1", pcon->
GetPhi1(),
"lower phi limit");
AddMemberInfo(
pt,
"fDphi", pcon->
GetDphi(),
"phi range");
AddMemberInfo(
pt,
"fNz", pcon->
GetNz(),
"number of z planes");
}
AddExecInfo(
pt,
"pcon",
"2 or 3 (Phi, Z)");
}
{
auto c = create_canvas(
"A polygone");
if (iaxis == 2 || iaxis == 3) {
if (!slice)
return;
}
if (iaxis) {
printf("Wrong division axis %d. Allowed range is 2-3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fPhi1", pgon->
GetPhi1(),
"lower phi limit");
AddMemberInfo(
pt,
"fDphi", pgon->
GetDphi(),
"phi range");
AddMemberInfo(
pt,
"fNedges", pgon->
GetNedges(),
"number of edges");
AddMemberInfo(
pt,
"fNz", pgon->
GetNz(),
"number of z planes");
}
AddExecInfo(
pt,
"pgon",
"2 or 3 (Phi, Z)");
}
void arb8()
{
auto c = create_canvas(
"An arbitrary polyhedron");
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fDz", arb->
GetDz(),
"Z half length");
text =
pt->AddText(
"Vertices on lower Z plane:");
for (
Int_t i = 0; i < 4; i++) {
text->SetTextSize(0.043);
}
text =
pt->AddText(
"Vertices on higher Z plane:");
for (
Int_t i = 4; i < 8; i++) {
text->SetTextSize(0.043);
}
}
{
auto c = create_canvas(
"A trapezoid with dX and dY varying with Z");
if (iaxis == 3) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed is only 3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
AddMemberInfo(
pt,
"fDx1", trd2->
GetDx1(),
"half length in X at lower Z surface(-dz)");
AddMemberInfo(
pt,
"fDx2", trd2->
GetDx2(),
"half length in X at higher Z surface(+dz)");
AddMemberInfo(
pt,
"fDy1", trd2->
GetDy1(),
"half length in Y at lower Z surface(-dz)");
AddMemberInfo(
pt,
"fDy2", trd2->
GetDy2(),
"half length in Y at higher Z surface(-dz)");
AddMemberInfo(
pt,
"fDz", trd2->
GetDz(),
"half length in Z");
AddExecInfo(
pt,
"trd2",
"only 3 (Z)");
}
{
auto c = create_canvas(
"A more general trapezoid");
TGeoVolume *vol =
gGeoManager->MakeTrap(
"Trap", med, 30, 15, 30, 20, 10, 15, 0, 20, 10, 15, 0);
if (iaxis == 3) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed is only 3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
TText *
text =
pt->AddText(
"TGeoTrap - Trapezoid class");
AddMemberInfo(
pt,
"fDz", trap->
GetDz(),
"half length in Z");
AddMemberInfo(
pt,
"fTheta", trap->
GetTheta(),
"theta angle of trapezoid axis");
AddMemberInfo(
pt,
"fPhi", trap->
GetPhi(),
"phi angle of trapezoid axis");
AddMemberInfo(
pt,
"fH1", trap->
GetH1(),
"half length in y at -fDz");
AddMemberInfo(
pt,
"fAlpha1", trap->
GetAlpha1(),
"angle between centers of x edges and y axis at -fDz");
AddMemberInfo(
pt,
"fBl1", trap->
GetBl1(),
"half length in x at -dZ and y=-fH1");
AddMemberInfo(
pt,
"fTl1", trap->
GetTl1(),
"half length in x at -dZ and y=+fH1");
AddMemberInfo(
pt,
"fH2", trap->
GetH2(),
"half length in y at +fDz");
AddMemberInfo(
pt,
"fBl2", trap->
GetBl2(),
"half length in x at +dZ and y=-fH1");
AddMemberInfo(
pt,
"fTl2", trap->
GetTl2(),
"half length in x at +dZ and y=+fH1");
AddMemberInfo(
pt,
"fAlpha2", trap->
GetAlpha2(),
"angle between centers of x edges and y axis at +fDz");
AddExecInfo(
pt,
"trap",
"only 3 (Z)");
}
{
auto c = create_canvas(
"A twisted trapezoid");
TGeoVolume *vol =
gGeoManager->MakeGtra(
"Gtra", med, 30, 15, 30, 30, 20, 10, 15, 0, 20, 10, 15, 0);
if (iaxis == 3) {
if (!slice)
return;
} else if (iaxis) {
printf("Wrong division axis %d. Allowed is only 3.\n", iaxis);
return;
}
MakePicture();
if (!comments)
return;
TText *
text =
pt->AddText(
"TGeoGtra - Twisted trapezoid class");
AddMemberInfo(
pt,
"fDz", trap->
GetDz(),
"half length in Z");
AddMemberInfo(
pt,
"fTheta", trap->
GetTheta(),
"theta angle of trapezoid axis");
AddMemberInfo(
pt,
"fPhi", trap->
GetPhi(),
"phi angle of trapezoid axis");
AddMemberInfo(
pt,
"fH1", trap->
GetH1(),
"half length in y at -fDz");
AddMemberInfo(
pt,
"fAlpha1", trap->
GetAlpha1(),
"angle between centers of x edges and y axis at -fDz");
AddMemberInfo(
pt,
"fBl1", trap->
GetBl1(),
"half length in x at -dZ and y=-fH1");
AddMemberInfo(
pt,
"fTl1", trap->
GetTl1(),
"half length in x at -dZ and y=+fH1");
AddMemberInfo(
pt,
"fH2", trap->
GetH2(),
"half length in y at +fDz");
AddMemberInfo(
pt,
"fBl2", trap->
GetBl2(),
"half length in x at +dZ and y=-fH1");
AddMemberInfo(
pt,
"fTl2", trap->
GetTl2(),
"half length in x at +dZ and y=+fH1");
AddMemberInfo(
pt,
"fAlpha2", trap->
GetAlpha2(),
"angle between centers of x edges and y axis at +fDz");
AddExecInfo(
pt,
"gtra",
"only 3 (Z)");
}
void xtru()
{
auto c = create_canvas(
"A twisted trapezoid");
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");
AddMemberInfo(
pt,
"fNvert", xtru->
GetNvert(),
"number of polygone vertices");
AddMemberInfo(
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 tessellated()
{
auto c = create_canvas(
"A tessellated shape");
std::vector<Tessellated::Vertex_t> vert;
vert.reserve(120);
vert.emplace_back(0, 0.5 * (1 + sqrt5), -1);
vert.emplace_back(0, 0.5 * (-1 + sqrt5), 0.5 * (-1 - sqrt5));
vert.emplace_back(-1, 0, 0.5 * (-1 - sqrt5));
vert.emplace_back(-1, 1, -1);
vert.emplace_back(1, 1, -1);
vert.emplace_back(0, 0.5 * (1 + sqrt5), -1);
vert.emplace_back(0, 0.5 * (-1 + sqrt5), 0.5 * (-1 - sqrt5));
vert.emplace_back(1, 0, 0.5 * (-1 - sqrt5));
vert.emplace_back(1, 1, -1);
vert.emplace_back(0, 0.5 * (1 + sqrt5), -1);
vert.emplace_back(0.5 * (-1 + sqrt5), 0.5 * (1 + sqrt5), 0);
vert.emplace_back(0.5 * (1 + sqrt5), 1, 0);
vert.emplace_back(0.5 * (1 - sqrt5), 0.5 * (1 + sqrt5), 0);
vert.emplace_back(0, 0.5 * (1 + sqrt5), -1);
vert.emplace_back(0.5 * (-1 + sqrt5), 0.5 * (1 + sqrt5), 0);
vert.emplace_back(0, 0.5 * (1 + sqrt5), 1);
vert.emplace_back(0.5 * (1 - sqrt5), 0.5 * (1 + sqrt5), 0);
vert.emplace_back(0, 0.5 * (1 + sqrt5), -1);
vert.emplace_back(-1, 1, -1);
vert.emplace_back(0.5 * (-1 - sqrt5), 1, 0);
vert.emplace_back(1, 1, -1);
vert.emplace_back(0.5 * (1 + sqrt5), 1, 0);
vert.emplace_back(0.5 * (1 + sqrt5), 0, 0.5 * (1 - sqrt5));
vert.emplace_back(1, 0, 0.5 * (-1 - sqrt5));
vert.emplace_back(0.5 * (1 + sqrt5), 0, 0.5 * (1 - sqrt5));
vert.emplace_back(0.5 * (1 + sqrt5), -1, 0);
vert.emplace_back(1, -1, -1);
vert.emplace_back(1, 0, 0.5 * (-1 - sqrt5));
vert.emplace_back(1, -1, -1);
vert.emplace_back(0, 0.5 * (-1 - sqrt5), -1);
vert.emplace_back(0, 0.5 * (1 - sqrt5), 0.5 * (-1 - sqrt5));
vert.emplace_back(1, 0, 0.5 * (-1 - sqrt5));
vert.emplace_back(1, 0, 0.5 * (-1 - sqrt5));
vert.emplace_back(0, 0.5 * (-1 + sqrt5), 0.5 * (-1 - sqrt5));
vert.emplace_back(-1, 0, 0.5 * (-1 - sqrt5));
vert.emplace_back(0, 0.5 * (1 - sqrt5), 0.5 * (-1 - sqrt5));
vert.emplace_back(0.5 * (-1 + sqrt5), 0.5 * (1 + sqrt5), 0);
vert.emplace_back(0.5 * (1 + sqrt5), 1, 0);
vert.emplace_back(1, 1, 1);
vert.emplace_back(0, 0.5 * (1 + sqrt5), 1);
vert.emplace_back(0.5 * (1 + sqrt5), 1, 0);
vert.emplace_back(1, 1, 1);
vert.emplace_back(1, 0, 0.5 * (1 + sqrt5));
vert.emplace_back(0.5 * (1 + sqrt5), 0, 0.5 * (-1 + sqrt5));
vert.emplace_back(0.5 * (1 + sqrt5), 0, 0.5 * (1 - sqrt5));
vert.emplace_back(0.5 * (1 + sqrt5), 1, 0);
vert.emplace_back(0.5 * (1 + sqrt5), 0, 0.5 * (-1 + sqrt5));
vert.emplace_back(0.5 * (1 + sqrt5), -1, 0);
vert.emplace_back(0.5 * (1 - sqrt5), 0.5 * (1 + sqrt5), 0);
vert.emplace_back(0, 0.5 * (1 + sqrt5), 1);
vert.emplace_back(-1, 1, 1);
vert.emplace_back(0.5 * (-1 - sqrt5), 1, 0);
vert.emplace_back(0, 0.5 * (1 + sqrt5), 1);
vert.emplace_back(0, 0.5 * (-1 + sqrt5), 0.5 * (1 + sqrt5));
vert.emplace_back(-1, 0, 0.5 * (1 + sqrt5));
vert.emplace_back(-1, 1, 1);
vert.emplace_back(1, 1, 1);
vert.emplace_back(0, 0.5 * (1 + sqrt5), 1);
vert.emplace_back(0, 0.5 * (-1 + sqrt5), 0.5 * (1 + sqrt5));
vert.emplace_back(1, 0, 0.5 * (1 + sqrt5));
vert.emplace_back(0, 0.5 * (1 - sqrt5), 0.5 * (1 + sqrt5));
vert.emplace_back(-1, 0, 0.5 * (1 + sqrt5));
vert.emplace_back(0, 0.5 * (-1 + sqrt5), 0.5 * (1 + sqrt5));
vert.emplace_back(1, 0, 0.5 * (1 + sqrt5));
vert.emplace_back(0, 0.5 * (1 - sqrt5), 0.5 * (1 + sqrt5));
vert.emplace_back(1, 0, 0.5 * (1 + sqrt5));
vert.emplace_back(1, -1, 1);
vert.emplace_back(0, 0.5 * (-1 - sqrt5), 1);
vert.emplace_back(0.5 * (1 + sqrt5), 0, 0.5 * (-1 + sqrt5));
vert.emplace_back(0.5 * (1 + sqrt5), -1, 0);
vert.emplace_back(1, -1, 1);
vert.emplace_back(1, 0, 0.5 * (1 + sqrt5));
vert.emplace_back(-1, 0, 0.5 * (1 + sqrt5));
vert.emplace_back(-1, 1, 1);
vert.emplace_back(0.5 * (-1 - sqrt5), 1, 0);
vert.emplace_back(0.5 * (-1 - sqrt5), 0, 0.5 * (-1 + sqrt5));
vert.emplace_back(-1, -1, 1);
vert.emplace_back(-1, 0, 0.5 * (1 + sqrt5));
vert.emplace_back(0.5 * (-1 - sqrt5), 0, 0.5 * (-1 + sqrt5));
vert.emplace_back(0.5 * (-1 - sqrt5), -1, 0);
vert.emplace_back(0, 0.5 * (1 - sqrt5), 0.5 * (1 + sqrt5));
vert.emplace_back(-1, 0, 0.5 * (1 + sqrt5));
vert.emplace_back(-1, -1, 1);
vert.emplace_back(0, 0.5 * (-1 - sqrt5), 1);
vert.emplace_back(0.5 * (-1 - sqrt5), -1, 0);
vert.emplace_back(0.5 * (-1 - sqrt5), 0, 0.5 * (1 - sqrt5));
vert.emplace_back(0.5 * (-1 - sqrt5), 1, 0);
vert.emplace_back(0.5 * (-1 - sqrt5), 0, 0.5 * (-1 + sqrt5));
vert.emplace_back(0.5 * (-1 - sqrt5), -1, 0);
vert.emplace_back(0.5 * (-1 - sqrt5), 0, 0.5 * (1 - sqrt5));
vert.emplace_back(-1, 0, 0.5 * (-1 - sqrt5));
vert.emplace_back(-1, -1, -1);
vert.emplace_back(0, 0.5 * (-1 - sqrt5), -1);
vert.emplace_back(0.5 * (1 - sqrt5), 0.5 * (-1 - sqrt5), 0);
vert.emplace_back(0.5 * (-1 - sqrt5), -1, 0);
vert.emplace_back(-1, -1, -1);
vert.emplace_back(0.5 * (1 - sqrt5), 0.5 * (-1 - sqrt5), 0);
vert.emplace_back(0.5 * (-1 - sqrt5), -1, 0);
vert.emplace_back(-1, -1, 1);
vert.emplace_back(0, 0.5 * (-1 - sqrt5), 1);
vert.emplace_back(-1, 1, -1);
vert.emplace_back(-1, 0, 0.5 * (-1 - sqrt5));
vert.emplace_back(0.5 * (-1 - sqrt5), 0, 0.5 * (1 - sqrt5));
vert.emplace_back(0.5 * (-1 - sqrt5), 1, 0);
vert.emplace_back(0, 0.5 * (-1 - sqrt5), -1);
vert.emplace_back(0, 0.5 * (1 - sqrt5), 0.5 * (-1 - sqrt5));
vert.emplace_back(-1, 0, 0.5 * (-1 - sqrt5));
vert.emplace_back(-1, -1, -1);
vert.emplace_back(0, 0.5 * (-1 - sqrt5), -1);
vert.emplace_back(0.5 * (1 - sqrt5), 0.5 * (-1 - sqrt5), 0);
vert.emplace_back(0, 0.5 * (-1 - sqrt5), 1);
vert.emplace_back(0.5 * (-1 + sqrt5), 0.5 * (-1 - sqrt5), 0);
vert.emplace_back(1, -1, -1);
vert.emplace_back(0.5 * (1 + sqrt5), -1, 0);
vert.emplace_back(0.5 * (-1 + sqrt5), 0.5 * (-1 - sqrt5), 0);
vert.emplace_back(0, 0.5 * (-1 - sqrt5), -1);
vert.emplace_back(0.5 * (1 + sqrt5), -1, 0);
vert.emplace_back(1, -1, 1);
vert.emplace_back(0, 0.5 * (-1 - sqrt5), 1);
vert.emplace_back(0.5 * (-1 + sqrt5), 0.5 * (-1 - sqrt5), 0);
tsl->
AddFacet(vert[0], vert[1], vert[2], vert[3]);
tsl->
AddFacet(vert[4], vert[7], vert[6], vert[5]);
tsl->
AddFacet(vert[8], vert[9], vert[10], vert[11]);
tsl->
AddFacet(vert[12], vert[15], vert[14], vert[13]);
tsl->
AddFacet(vert[16], vert[17], vert[18], vert[19]);
tsl->
AddFacet(vert[20], vert[21], vert[22], vert[23]);
tsl->
AddFacet(vert[24], vert[25], vert[26], vert[27]);
tsl->
AddFacet(vert[28], vert[29], vert[30], vert[31]);
tsl->
AddFacet(vert[32], vert[35], vert[34], vert[33]);
tsl->
AddFacet(vert[36], vert[39], vert[38], vert[37]);
tsl->
AddFacet(vert[40], vert[41], vert[42], vert[43]);
tsl->
AddFacet(vert[44], vert[45], vert[46], vert[47]);
tsl->
AddFacet(vert[48], vert[51], vert[50], vert[49]);
tsl->
AddFacet(vert[52], vert[55], vert[54], vert[53]);
tsl->
AddFacet(vert[56], vert[57], vert[58], vert[59]);
tsl->
AddFacet(vert[60], vert[63], vert[62], vert[61]);
tsl->
AddFacet(vert[64], vert[67], vert[66], vert[65]);
tsl->
AddFacet(vert[68], vert[71], vert[70], vert[69]);
tsl->
AddFacet(vert[72], vert[73], vert[74], vert[75]);
tsl->
AddFacet(vert[76], vert[77], vert[78], vert[79]);
tsl->
AddFacet(vert[80], vert[81], vert[82], vert[83]);
tsl->
AddFacet(vert[84], vert[87], vert[86], vert[85]);
tsl->
AddFacet(vert[88], vert[89], vert[90], vert[91]);
tsl->
AddFacet(vert[92], vert[93], vert[94], vert[95]);
tsl->
AddFacet(vert[96], vert[99], vert[98], vert[97]);
tsl->
AddFacet(vert[100], vert[101], vert[102], vert[103]);
tsl->
AddFacet(vert[104], vert[107], vert[106], vert[105]);
tsl->
AddFacet(vert[108], vert[111], vert[110], vert[109]);
tsl->
AddFacet(vert[112], vert[113], vert[114], vert[115]);
tsl->
AddFacet(vert[116], vert[117], vert[118], vert[119]);
MakePicture();
if (!comments)
return;
TText *
text =
pt->AddText(
"TGeoTessellated - Tessellated shape class");
AddMemberInfo(
pt,
"fNfacets", tsl->
GetNfacets(),
"number of facets");
AddMemberInfo(
pt,
"fNvertices", tsl->
GetNvertices(),
"number of vertices");
pt->AddText(
"----- A tessellated shape is defined by the number of facets");
pt->AddText(
"----- facets can be added using AddFacet");
pt->AddText(
"----- Create with: TGeoTessellated *tsl = new TGeoTessellated(nfacets);");
AddExecInfo(
pt,
"tessellated");
}
void composite()
{
auto c = create_canvas(
"A Boolean shape composition");
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");
AddExecInfo(
pt,
"composite");
}
void ideal()
{
auto c = create_canvas(
"Ideal geometry");
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");
pt->SetAllWith(
"--",
"color", 4);
pt->SetAllWith(
"--",
"font", 72);
pt->SetAllWith(
"--",
"size", 0.04);
pt->SetAllWith(
"+",
"color", 2);
pt->SetAllWith(
"+",
"font", 72);
pt->SetAllWith(
"+",
"size", 0.04);
}
void align()
{
return;
printf("Click: <Ideal geometry> first\n");
return;
}
for (
Int_t i = 1; i <= 10; i++) {
for (
Int_t j = 1; j <= 10; j++) {
if (list)
if (!node)
} else {
}
}
}
}
}
void geodemo()
{
bar->
AddButton(
"How to run ",
"help()",
"Instructions for running this macro");
"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(
"Tessellated ",
"tessellated()",
"A tessellated shape");
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");
}
int Int_t
Signed integer 4 bytes (int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
double Double_t
Double 8 bytes.
externTGeoManager * gGeoManager
virtual void SetFillColor(Color_t fcolor)
Set the fill area color.
virtual void SetTextAlign(Short_t align=11)
Set the text alignment.
virtual void SetTextColor(Color_t tcolor=1)
Set the text color.
virtual void SetTextFont(Font_t tfont=62)
Set the text font.
virtual void SetTextSize(Float_t tsize=1)
Set the text size.
A Control Bar is a fully user configurable tool which provides fast access to frequently used operati...
void Show()
Show control bar.
void AddButton(TControlBarButton *button)
Add button.
virtual void SetVertex(Int_t vnum, Double_t x, Double_t y)
virtual Double_t GetDZ() const
Composite shapes are Boolean combinations of two or more shape components.
virtual Double_t GetRmax2() const
virtual Double_t GetRmin2() const
virtual Double_t GetRmin1() const
virtual Double_t GetRmax1() const
virtual Double_t GetA() const
virtual Double_t GetB() const
Double_t GetTwistAngle() const
Double_t GetStOut() const
The manager class for any TGeo geometry.
Base class describing materials.
virtual void RegisterYourself()
Register the matrix in the current manager, which will become the owner.
Media are used to store properties related to tracking and which are useful only when using geometry ...
virtual TGeoMatrix * GetMatrix() const =0
Double_t GetAlpha() const
Double_t GetTheta() const
A paraboloid is defined by the revolution surface generated by a parabola and is bounded by two plane...
base finder class for patterns. A pattern is specifying a division type
TGeoVolume * GetVolume() const
Double_t GetStart() const
Double_t * GetRmax() const
virtual void DefineSection(Int_t snum, Double_t z, Double_t rmin, Double_t rmax)
Double_t * GetRmin() const
Physical nodes are the actual 'touchable' objects in the geometry, representing a path of positioned ...
TGeoNode * GetNode(Int_t level=-1) const
Return node in branch at LEVEL. If not specified, return last leaf.
Bool_t Align(TGeoMatrix *newmat=nullptr, TGeoShape *newshape=nullptr, Bool_t check=kFALSE, Double_t ovlp=0.001)
Align a physical node with a new relative matrix/shape.
Base abstract class for all shapes.
virtual const char * GetAxisName(Int_t iaxis) const =0
virtual Double_t GetRmin() const
Double_t GetTheta2() const
virtual Double_t GetRmax() const
Double_t GetTheta1() const
bool AddFacet(const Vertex_t &pt0, const Vertex_t &pt1, const Vertex_t &pt2)
Adding a triangular facet from vertex positions in absolute coordinates.
Class describing translations.
void SetTranslation(Double_t dx, Double_t dy, Double_t dz)
Set translation components.
Double_t GetAlpha2() const
Double_t GetTheta() const
Double_t GetAlpha1() const
virtual Double_t GetRmin() const
virtual Double_t GetDz() const
virtual Double_t GetRmax() const
TGeoVolume, TGeoVolumeMulti, TGeoVolumeAssembly are the volume classes.
void SetLineWidth(Width_t lwidth) override
Set the line width.
virtual TGeoNode * AddNode(TGeoVolume *vol, Int_t copy_no, TGeoMatrix *mat=nullptr, Option_t *option="")
Add a TGeoNode to the list of nodes.
void Draw(Option_t *option="") override
draw top volume according to option
TGeoPatternFinder * GetFinder() const
void SetLineColor(Color_t lcolor) override
Set the line color.
TGeoShape * GetShape() const
virtual TGeoVolume * Divide(const char *divname, Int_t iaxis, Int_t ndiv, Double_t start, Double_t step, Int_t numed=0, Option_t *option="")
Division a la G3.
A TGeoXtru shape is represented by the extrusion of an arbitrary polygon with fixed outline between s...
Bool_t DefinePolygon(Int_t nvert, const Double_t *xv, const Double_t *yv)
Creates the polygon representing the blueprint of any Xtru section.
virtual void DefineSection(Int_t snum, Double_t z, Double_t x0=0., Double_t y0=0., Double_t scale=1.)
defines z position of a section plane, rmin and rmax at this z.
const char * GetName() const override
Returns name of object.
virtual void SetName(const char *name)
Set the name of the TNamed.
Mother of all ROOT objects.
void Draw(Option_t *option="") override
Draw this pave with its current attributes.
virtual void SetAllWith(const char *text, Option_t *option, Double_t value)
virtual TText * AddText(Double_t x1, Double_t y1, const char *label)
Bool_t ProcessEvents()
Process events if timer did time out.
Random number generator class based on M.
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
virtual Double_t GetPsi()=0
virtual Double_t GetLongitude()=0
virtual void ShowAxis()=0
virtual Double_t GetLatitude()=0
virtual void SetView(Double_t longitude, Double_t latitude, Double_t psi, Int_t &irep)=0
Abstract class for geometry painters.
void box(Int_t pat, Double_t x1, Double_t y1, Double_t x2, Double_t y2)
Double_t Sqrt(Double_t x)
Returns the square root of x.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.