Re: Problem in implementation of a TGeo volume with holes

From: Andrei Gheata <Andrei.Gheata_at_cern.ch>
Date: Fri, 06 Jul 2007 17:11:09 +0200


Hi Alberto,

It is a perfectly valid shape - looks more like a GL viewer artefact. Raytracing works correctly - this means the volume is good for tracking.

Cheers,
Andrei

Alberto Pulvirenti wrote:
> Dear ROOTers,
>
> in attachment you can find a macro which I am implementing to create a
> TGeo volume which should consist in a thin shape with some holes. The
> shape has a form not too regular, so I used TGeoXtru to define it,
> instead of gluing together plenty of boxes and Arb8 shapes.
> Then, I implemented the holes and I tried to compose the shape with the
> holes, and to generate a final volume with this kind of "pierced" volume
> whose shape I created.
>
> As you can see from the example plots, when I draw this object in the GL
> viewer, I notice that, if I see it from one side, it looks fine. If I
> look at it from the other side, it looks strange, because some part of
> the "filled" volume disappears.
>
> Could someone help me in understanding where's the problem?
>
> thanks and best regards
>
> Alberto
>
>
> ------------------------------------------------------------------------
>
> TGeoVolume* gfoil1(Bool_t kap = kTRUE, TGeoManager *mgr)
> {
> // load libraries
> gSystem->Load("libGeom");
> TGeoManager *mgr = new TGeoManager("test", "");
>
> // instantiate the media:
> // - vacuum for the container volume
> // - kapton for the pysical volumes
> TGeoMedium *vacuum = mgr->GetMedium("VACUUM");
>
> // conversion factor
> Double_t fgkmm = 0.1;
>
> // label
> char type[3];
> if (kap) strcpy(type, "KP"); else strcpy(type, "AL");
>
> // size of the virtual box containing exactly this volume
> Double_t length = fgkmm * 243.18;
> Double_t width = fgkmm * 15.95;
> Double_t thickness = fgkmm * 0.05;
> if (!kap) {
> length -= fgkmm * 0.4;
> width -= fgkmm * 0.4;
> thickness = fgkmm * 0.02;
> }
>
> // define the length of all sectors (from leftmost to rightmost)
> Int_t i;
> Double_t sectorLength[] = { 140.71, 2.48, 26.78, 4.00, 10.00, 24.40, 10.00, 24.81 };
> for (i = 0; i < 8; i++) sectorLength[i] *= fgkmm;
> if (!kap) {
> sectorLength[0] -= fgkmm * 0.2;
> sectorLength[4] -= fgkmm * 0.2;
> sectorLength[5] += fgkmm * 0.4;
> sectorLength[6] -= fgkmm * 0.4;
> }
>
> // as shown in the drawing, we have three different widths in this shape:
> Double_t widthMax = fgkmm * 15.95;
> Double_t widthMed1 = fgkmm * 15.00;
> Double_t widthMed2 = fgkmm * 11.00;
> Double_t widthMin = fgkmm * 4.40;
> if (!kap) {
> widthMax -= fgkmm * 0.4;
> widthMed1 -= fgkmm * 0.4;
> widthMed2 -= fgkmm * 0.4;
> widthMin -= fgkmm * 0.4;
> }
>
> // the vertices of the polygon are arrays correctly ordered in the counterclockwise direction:
> // initially we place the point 0 in the origin, and all others will be defined accordingly
> Double_t x[14], y[14];
> x[ 0] = 0.0;
> y[ 0] = 0.0;
>
> x[ 1] = x[0] + length;
> y[ 1] = 0.0;
>
> x[ 2] = x[1];
> y[ 2] = -widthMin;
>
> x[ 3] = x[2] - sectorLength[7];
> y[ 3] = y[2];
>
> x[ 4] = x[3];
> y[ 4] = -widthMed1;
>
> x[ 5] = x[4] - sectorLength[6];
> y[ 5] = y[4];
>
> x[ 6] = x[5];
> y[ 6] = -widthMin;
>
> x[ 7] = x[6] - sectorLength[5];
> y[ 7] = y[6];
>
> x[ 8] = x[7];
> y[ 8] = -widthMed2;
>
> x[ 9] = x[8] - sectorLength[4];
> y[ 9] = y[8];
>
> x[10] = x[9] - sectorLength[3];
> y[10] = -widthMed1;
>
> x[11] = x[10] - sectorLength[2];
> y[11] = y[10];
>
> x[12] = x[11] - sectorLength[1];
> y[12] = -widthMax;
>
> x[13] = x[0];
> y[13] = -widthMax;
>
> // then, we shift all points in such a way that the origin will be at the centers
> for (i = 0; i < 14; i++) {
> x[i] -= 0.5*length;
> y[i] += 0.5*width;
> }
>
> // create the shape
> TGeoXtru *shGroundFull = new TGeoXtru(2);
> shGroundFull->SetName(Form("SH_GFOIL_%s_FULL", type));
> shGroundFull->DefinePolygon(14, x, y);
> shGroundFull->DefineSection(0, -0.5*thickness, 0., 0., 1.0);
> shGroundFull->DefineSection(1, 0.5*thickness, 0., 0., 1.0);
>
> // this volume contains some holes which are here implemented as simple boxes
> // of fixed size, which are displaced along the shape itself and then composed
> // using the facilities of the TGeo package
>
> Double_t holeLength = fgkmm * 10.00;
> Double_t holeWidth = fgkmm * 7.50;
> Double_t holeSepX0 = fgkmm * 7.05; // separation between center of first hole and left border
> Double_t holeSepXC = fgkmm * 14.00; // separation between the centers of two consecutive holes
> Double_t holeSepX1 = fgkmm * 15.42; // separation between centers of 5th and 6th hole
> Double_t holeSepX2 = fgkmm * 22.00; // separation between centers of 10th and 11th hole
> if (!kap) {
> holeSepX0 -= fgkmm * 0.2;
> holeLength += fgkmm * 0.4;
> holeWidth += fgkmm * 0.4;
> }
>
> // X position of hole center (will change for each hole)
> Double_t holeX = -0.5*length;
> // Y position of center of all holes (= 4.4 mm from upper border)
> Double_t holeY = 0.5*(width - holeWidth) - widthMin;
> if (!kap) holeY += 0.04;
>
> // create a shape for the holes (common)
> TGeoBBox *shHole = new TGeoBBox(Form("%sGFOIL_HOLE", type), 0.5*holeLength, 0.5*holeWidth, 0.5*thickness + 0.01);
>
> // insert the holes in the XTRU shape:
> // starting from the first value of X, they are simply shifted along this axis
> char name[200];
> TGeoTranslation *transHole[11];
> TString strComposite(Form("SH_GFOIL_%s_FULL - (", type));
> for (Int_t i = 0; i < 11; i++) {
> // set the position of the hole, depending on index
> if (i == 0) {
> holeX += holeSepX0;
> }
> else if (i < 4) {
> holeX += holeSepXC;
> }
> else if (i == 4) {
> holeX += holeSepX1;
> }
> else if (i < 10) {
> holeX += holeSepXC;
> }
> else {
> holeX += holeSepX2;
> }
> cout << i << " --> X = " << holeX << endl;
> sprintf(name, "TR_GFOIL_%s_HOLE%d", type, i);
> transHole[i] = new TGeoTranslation(name, holeX, holeY, 0.0);
> transHole[i]->RegisterYourself();
> strComposite.Append(Form("%sGFOIL_HOLE:%s", type, name));
> if (i < 10) strComposite.Append("+"); else strComposite.Append(")");
> }
>
> // create composite shape (with holes)
> TGeoCompositeShape *shGround = new TGeoCompositeShape(Form("SH_GFOIL_%s", type), strComposite.Data());
>
> // create the volume
> TGeoVolume *vol = new TGeoVolume("VOL", shGround, vacuum);
>
> // close and draw
> mgr->SetTopVolume(vol);
> mgr->CloseGeometry();
> mgr->CheckOverlaps(0.001);
> mgr->SetVisLevel(0);
> vol->Draw("ogl");
> }
>
>
> ------------------------------------------------------------------------
>
>
> ------------------------------------------------------------------------
>
Received on Fri Jul 06 2007 - 17:20:16 CEST

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2007 - 17:50:02 CEST