TGeo hole not complete

Hi,

I have a TGeometry in which I need a hole through a material but whyever the hole is not complete (see attachment). Why is it?

Here the code:

void cap()
{
// gStyle->SetCanvasPreferGL(true);
   gSystem->Load("libGeom");

   TCanvas *c = new TCanvas("composite shape", "", 700, 1000);
   if (gGeoManager) delete gGeoManager;
   TGeoManager *geom = new TGeoManager("cap", "cap geometry");

//--- define some materials   
   TGeoMaterial *matVACUUM = new TGeoMaterial("VACUUM", 0,0,0);
   TGeoMaterial *matPOLYAMID = new TGeoMaterial("polyamid-12", 197.3,110,1.06);      

//--- define some media
   TGeoMedium *VACUUM = new TGeoMedium("VACUUM",1, matVACUUM);
   TGeoMedium *POLYAMID = new TGeoMedium("Root Material",2, matPOLYAMID);

//--- make World
   TGeoVolume *World = geom->MakeBox("World", VACUUM, 300., 300., 50.);
   gGeoManager->SetTopVolume(World);
   World->SetVisibility(kFALSE);

//--- define the transformations
// no translation
   TGeoTranslation *tr1 = new TGeoTranslation(0., 0., 0.);

// turn drilling
   TGeoRotation *rot1 = new TGeoRotation("rot1", 60., 90., 90.);

// turn and move drilling
   TGeoCombiTrans *combi1 = new TGeoCombiTrans(-5.,3.,0., rot1);
   combi1->SetName("combi1");

// make body_1 perpendicular
   TGeoRotation *rot2 = new TGeoRotation("rot2", 90., 90., 0.);

// move Body
   TGeoCombiTrans *combi2 = new TGeoCombiTrans(4.5,0.,0., rot2);
   combi2->SetName("combi2");

   TGeoCombiTrans *combi3 = new TGeoCombiTrans(11.,0.,0., rot2);
   combi3->SetName("combi3");

   TGeoCombiTrans *combi4 = new TGeoCombiTrans(15.,0.,0., rot2);
   combi3->SetName("combi4");

   combi1->RegisterYourself();
   combi2->RegisterYourself();
   combi3->RegisterYourself();
   combi4->RegisterYourself();

// Ceeate Sphere
   TGeoVolume *Sphere_V = geom->MakeSphere("Sphere", POLYAMID, 5., 7., 0., 180., 90., -90.);
   Sphere_V->SetLineColor(kRed);
   TGeoSphere *Sphere = (TGeoSphere*)Sphere_V->GetShape();

// Create Drilling
   //                (name, medium, rmin, rmax, dz, phi_start, phi_end)
   TGeoVolume *Tube_V = geom->MakeTubs("Tube", POLYAMID, 0., 1., 1.2, 180.1, -180.1);   
   Tube_V->SetLineColor(kBlue);
   TGeoSphere *Tube = (TGeoSphere*)Tube_V->GetShape();

// Create Tube
   TGeoVolume *Body_1 = geom->MakeTube("Body_1", POLYAMID, 5., 7., 4.5);   
   Body_1->SetLineColor(kRed);

   TGeoVolume *Body_2 = geom->MakeTube("Body_2", POLYAMID, 5., 8., 2.);   
   Body_2->SetLineColor(kBlue);

   TGeoVolume *Body_3 = geom->MakeTube("Body_3", POLYAMID, 5., 5.5, 2.);   
   Body_3->SetLineColor(kRed);

// Add nodes to the world
   World->AddNode(Body_1, 1, combi2);
   World->AddNode(Body_2, 2, combi3);
   World->AddNode(Body_3, 3, combi4);

// cut drilling out of the sphere
   TGeoCompositeShape * cs = new TGeoCompositeShape("mir","(Sphere)-(Tube:combi1)");

   TGeoVolume *comp = new TGeoVolume("COMP",cs);
   comp->SetLineColor(kBlue);

// Add new composite node to the world
   World->AddNode(comp, 1);

//--- close the geometry
   geom->CloseGeometry();
   gGeoManager->SetNsegments(50);

//--- Make the geometries
   World->Draw("");

}

Has anyone an idea? Thank you in advance!

I did not run your code but it is maybe a display issue. One is already reported here and looks quite similar.

Yes, that also explains why I get different results by varying the angle just very less. Ok, thank you!
I guess there is no workaround for that (other display modus or so) ?

@agheata are you aware of any plan to fix/improve that?

Hi,

me again, i’m having problems to compose two shapes:

Error in TGeoBoolNode::MakeBranch: shape Foil_out not found
Error in TGeoBoolNode::MakeBranch: shape Foil_out not found

I guess it’s related to the fact that

	TGeoManager *geom = new TGeoManager("cap", "cap geometry");
	TGeoVolume *Body_3 = geom->MakeTube("Body_3", POLYAMID, 5., 5.5, 2.);	

worked but

	TGeoArb8 *arb2 = new TGeoArb8(100.08175);
	TGeoVolume *Foil_out_V = new TGeoVolume("Foil_out",arb2,VM);

does not. To be honest, I didn’t understand this geomanager but I guess I have to connect the foil_out_v volume to the geomanager? If yes, how?

Thank you very much in advance!

The code:

void cap()
{
// gStyle->SetCanvasPreferGL(true);
	gSystem->Load("libGeom");

// Materials remain to be defined exactly !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

	TCanvas *c = new TCanvas("composite shape", "", 700, 1000);
	if (gGeoManager) delete gGeoManager;
	TGeoManager *geom = new TGeoManager("cap", "cap geometry");

//--- define some materials   // lauryl­lactam, out of molar mass distribution
						 // Name, molecular weight, density
	TGeoMaterial *matVACUUM = new TGeoMaterial("VACUUM", 0,0,0);	// Consider p12 as a tmixture!   TGeoMaterial *matPOLYAMID = new TGeoMaterial("polyamid-12", 197.3,110,1.06, Solid,  291.15);
	TGeoMaterial *matPOLYAMID = new TGeoMaterial("polyamid-12", 197.3,110,1.06);			
	TGeoMaterial *matPWO = new TGeoMaterial("PWO", 10,10,1);
	TGeoMaterial *matVM2000 = new TGeoMaterial("VM2000", 10,10,1);

//--- define some media
	TGeoMedium *VACUUM = new TGeoMedium("VACUUM",1, matVACUUM);
	TGeoMedium *POLYAMID = new TGeoMedium("Polyamid",2, matPOLYAMID);
	TGeoMedium *PWO = new TGeoMedium("PWO",3, matPWO);
	TGeoMedium *VM = new TGeoMedium("VM",4, matVM2000);

//--- make World
	TGeoVolume *World = geom->MakeBox("World", VACUUM, 300., 300., 50.);
	gGeoManager->SetTopVolume(World);
	World->SetVisibility(kFALSE);

//--- view
//	TView3D *view = (TView3D*) TView::CreateView(1);
//	view->SetRange(500,500,500,250,250,250);
//	view->ZoomIn();

//--- define the transformations
// no translation
	TGeoTranslation *tr1 = new TGeoTranslation(0., 0., 0.);

// turn drilling
	TGeoRotation *rot1 = new TGeoRotation("rot1", 60., 90., 90.);

// turn and move drilling
	TGeoCombiTrans *combi1 = new TGeoCombiTrans(-5.,3.,0., rot1);
	combi1->SetName("combi1");

// make body_1 perpendicular
	TGeoRotation *rot2 = new TGeoRotation("rot2", 90., 90., 0.);

// move Body
	TGeoCombiTrans *combi2 = new TGeoCombiTrans(4.5,0.,0., rot2);
	combi2->SetName("combi2");

	TGeoCombiTrans *combi3 = new TGeoCombiTrans(11.,0.,0., rot2);
	combi3->SetName("combi3");

	TGeoCombiTrans *combi4 = new TGeoCombiTrans(15.,0.,0., rot2);
	combi4->SetName("combi4");

//turn and move crystal
	TGeoCombiTrans *combi5 = new TGeoCombiTrans(117.0,0.,0., rot2);				// 63.5µm foil and 100µm space of air in between crystal and foil
	combi5->SetName("combi5");

// register
	combi1->RegisterYourself();
	combi2->RegisterYourself();
	combi3->RegisterYourself();
	combi4->RegisterYourself();
	combi5->RegisterYourself();

// Ceeate Sphere
	TGeoVolume *Sphere_V = geom->MakeSphere("Sphere", POLYAMID, 5., 7., 0., 180., 90., -90.);
	Sphere_V->SetLineColor(kRed);
	TGeoSphere *Sphere = (TGeoSphere*)Sphere_V->GetShape();

// Create Drilling
	//				    (name, medium, rmin, rmax, dz, phi_start, phi_end)
	TGeoVolume *Tube_V = geom->MakeTubs("Tube", POLYAMID, 0., 1., 1.2, -180., 180.);	
	Tube_V->SetLineColor(kBlue);
	TGeoSphere *Tube = (TGeoSphere*)Tube_V->GetShape();

// Create Tube
	TGeoVolume *Body_1 = geom->MakeTube("Body_1", POLYAMID, 5., 7., 4.5);	
	Body_1->SetLineColor(kRed);

	TGeoVolume *Body_2 = geom->MakeTube("Body_2", POLYAMID, 5., 8., 2.);	
	Body_2->SetLineColor(kBlue);

	TGeoVolume *Body_3 = geom->MakeTube("Body_3", POLYAMID, 5., 5.5, 2.);	
	Body_3->SetLineColor(kRed);

// Create Crystal
	TGeoArb8 *arb = new TGeoArb8(100);
	// lower xy-plane
	arb->SetVertex(0,-10.89,-10.64);
	arb->SetVertex(1,-10.89,10.64);
	arb->SetVertex(2,10.89,10.64);
	arb->SetVertex(3,10.89,-10.64);
	// upper xy-plane
	arb->SetVertex(4,-10.89,-10.64);
	arb->SetVertex(5,-10.89,10.64);
	arb->SetVertex(6,10.89,10.64);
	arb->SetVertex(7,10.89,-10.64);

	TGeoVolume *Crystal = new TGeoVolume("Crystal",arb,PWO);
	Crystal->SetLineColor(kBlue);

// Create foil outer edges
	// 163.5µm / 2 =  0.1635mm / 2 = 0.08175mm
	TGeoArb8 *arb2 = new TGeoArb8(100.08175);
	Double_t outer_foil = 0.08175;
	// lower xy-plane
	arb2->SetVertex(0,-10.89-outer_foil,-10.64-outer_foil);
	arb2->SetVertex(1,-10.89-outer_foil,10.64+outer_foil);
	arb2->SetVertex(2,10.89+outer_foil,10.64+outer_foil);
	arb2->SetVertex(3,10.89+outer_foil,-10.64-outer_foil);
	// upper xy-plane
	arb2->SetVertex(4,-10.89-outer_foil,-10.64-outer_foil);
	arb2->SetVertex(5,-10.89-outer_foil,10.64+outer_foil);
	arb2->SetVertex(6,10.89+outer_foil,10.64+outer_foil);
	arb2->SetVertex(7,10.89+outer_foil,-10.64-outer_foil);

	TGeoVolume *Foil_out_V = new TGeoVolume("Foil_out",arb2,VM);
	Foil_out_V->SetLineColor(kGreen);
	TGeoSphere *Foil_out = (TGeoSphere*)Foil_out_V->GetShape();


// Create foil inner edges
	// 100µm / 2 =  0.05mm / 2 = 0.05mm
	TGeoArb8 *arb3 = new TGeoArb8(100.05);
	Double_t inner_foil = 0.05;
	// lower xy-plane
	arb3->SetVertex(0,-10.89-inner_foil,-10.64-inner_foil);
	arb3->SetVertex(1,-10.89-inner_foil,10.64+inner_foil);
	arb3->SetVertex(2,10.89+inner_foil,10.64+inner_foil);
	arb3->SetVertex(3,10.89+inner_foil,-10.64-inner_foil);
	// upper xy-plane
	arb3->SetVertex(4,-10.89-inner_foil,-10.64-inner_foil);
	arb3->SetVertex(5,-10.89-inner_foil,10.64+inner_foil);
	arb3->SetVertex(6,10.89+inner_foil,10.64+inner_foil);
	arb3->SetVertex(7,10.89+inner_foil,-10.64-inner_foil);

	TGeoVolume *Foil_in_V = new TGeoVolume("Foil_in",arb3,VM);
	Foil_in_V->SetLineColor(kRed);
	TGeoSphere *Foil_in = (TGeoSphere*)Foil_in_V->GetShape();

// Add nodes to the world
	World->AddNode(Body_1, 1, combi2);
	World->AddNode(Body_2, 2, combi3);
	World->AddNode(Body_3, 3, combi4);
	World->AddNode(Crystal, 4, combi5);
	World->AddNode(Foil_in_V, 5, combi5);
	World->AddNode(Foil_out_V, 6, combi5);

// make drilling into the sphere
	// Union:
	TGeoUnion("Sphere","Tube");
	TGeoCompositeShape * cs1 = new TGeoCompositeShape("drilling","(Sphere)-(Tube:combi1)");
	TGeoVolume *comp1 = new TGeoVolume("COMP1",cs1);
	comp1->SetLineColor(kBlue);

// cut foil
	// Union:
	TGeoUnion("Foil_out","Foil_in");
	TGeoCompositeShape * cs2 = new TGeoCompositeShape("foil","(Foil_out:combi5)-(Foil_in:combi5)");
	//TGeoVolume *comp2 = new TGeoVolume("COMP2",cs2);
	//comp2->SetLineColor(kBlue);


// Add new composite node to the world
	World->AddNode(comp1, 1);
//	World->AddNode(comp2, 2);

//--- close the geometry
	geom->CloseGeometry();
	gGeoManager->SetNsegments(50);

//--- Make the geometries visible
	//geom->SetVisLevel(4);
//	World->Draw("ogle");
	World->Draw("");

	//TView *view = gPad->GetView();
	//view->ShowAxis();

}

I still couldn’t work it out. In https://root.cern.ch/doc/master/classTGeoShape.html there is the following:

Creating shapes

Shape objects embed only the minimum set of parameters that are fully describing a valid physical shape. For instance, a tube is represented by its half length, the minimum radius and the maximum radius. Shapes are used together with media in order to create volumes, which in their turn are the main components of the geometrical tree. A specific shape can be created stand-alone :
TGeoBBox *box = new TGeoBBox(“s_box”, halfX, halfY, halfZ); // named
TGeoTube *tub = new TGeoTube(rmin, rmax, halfZ); // no name
… (see each specific shape constructors)

Sometimes it is much easier to create a volume having a given shape in one step, since shapes are not directly linked in the geometrical tree but volumes are :
TGeoVolume *vol_box = gGeoManager->MakeBox(“BOX_VOL”, “mat1”, halfX, halfY, halfZ);
TGeoVolume *vol_tub = gGeoManager->MakeTube(“TUB_VOL”, “mat2”, rmin, rmax, halfZ);
… (see MakeXXX() utilities in TGeoManager class)

But I don’t understand this. What do I have to do? In the first case I have to call a shape constructor (because I’m not using a volume created by a shape) but the Shape constructor:

TShape::TShape ( const char * name,
const char * title,
const char * material
)
https://root.cern.ch/doc/master/classTShape.html#aa7ea50da38ea85a5c23e1e96b56b5080

can’t know to which volume he has to be connected. As far as I understand. How is this might to be applied?

Ok, I got a workaround:

By replacing

TGeoArb8 *arb2 = new TGeoArb8(100.08175);
(…)
TGeoVolume *Foil_out_V = new TGeoVolume(“Foil_out”,arb2,VM);
Foil_out_V->SetLineColor(kGreen);
TGeoSphere Foil_out = (TGeoSphere)Foil_out_V->GetShape();

with

TGeoVolume *Foil_out_V = geom->MakeArb8(“Foil_out”, VM, 100.08175);
Foil_out_V->SetLineColor(kRed);
TGeoArb8 arb2 = (TGeoArb8)Foil_out_V->GetShape();

worked

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.