# Creating a Right Trapezoid Prism

**URL:** <https://root-forum.cern.ch/t/creating-a-right-trapezoid-prism/49458>\
**Category:** Newbie\
**Created:** [April 3, 2022, 6:37pm UTC](https://root-forum.cern.ch/t/creating-a-right-trapezoid-prism/49458 "2022-04-03T18:37:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Yasenya](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@Yasenya](https://root-forum.cern.ch/u/Yasenya)\
**Post date:** [April 3, 2022, 6:37pm UTC](https://root-forum.cern.ch/t/creating-a-right-trapezoid-prism/49458/1 "2022-04-03T18:37:46Z")

</div>

Hello All,  
I am a newbie to ROOT programming. I am using ROOT  
version : v6-24-06@v6-24-06 .

I am currently trying to construct a right triangular prism. I tried to do so by using the MakeTrd1 command. However I ended up with the following outputs. As it can be seen, the prism is expanding upwards in both directions.

 ![](https://root-forum.cern.ch/uploads/default/original/3X/3/4/348c9e265c50862218b0016a676576c999aa9dfa.png)  
 ![](https://root-forum.cern.ch/uploads/default/original/3X/e/2/e2de8f7e8f22672d9fd879ad8d0f04c697a8826d.png)

However, my goal is to construct a prism as in the following image (only one side of the prism should be extending from bottom to the top, right angles are the case for the other sides) :

 ![prism](https://root-forum.cern.ch/uploads/default/original/3X/9/5/950739d7eba82c3bb8b8b0d736d00bcac1957a03.jpeg)

The prism sizes are:

z axis: 30 cm  
y axis: 36 cm  
at the bottom end, length in x -axis is 6cm, at the top end, it is 24 cm.

Which command should I be using in order to create such a volume? Any help would be greatly appreciated.

---

<div class="post-metadata">

**Author:** ![dastudillo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/dastudillo/32/17280_2.png) [@dastudillo](https://root-forum.cern.ch/u/dastudillo)\
**Post date:** [April 4, 2022, 6:17am UTC](https://root-forum.cern.ch/t/creating-a-right-trapezoid-prism/49458/2 "2022-04-04T06:17:23Z")

</div>

Try [TGeoArb8](https://root.cern/doc/master/classTGeoArb8.html)

```auto
  Double_t verts[8][2];
  verts[0][0] = 0.;
  verts[0][1] = 0.;
  verts[1][0] = 0.;
  verts[1][1] = 36.;
  verts[2][0] = 6.;
  verts[2][1] = 36.;
  verts[3][0] = 6.;
  verts[3][1] = 0.;
  verts[4][0] = 0.;
  verts[4][1] = 0.;
  verts[5][0] = 0.;
  verts[5][1] = 36.;
  verts[6][0] = 24.;
  verts[6][1] = 36.;
  verts[7][0] = 24.;
  verts[7][1] = 0.;

  TGeoArb8 *c= new TGeoArb8(15,(Double_t*)verts);
  c->Draw();

```

 ![c1](https://root-forum.cern.ch/uploads/default/original/3X/2/c/2cf3af8c94782bbd0215dc949062d97f7a82795d.png)

---

<div class="post-metadata">

**Author:** ![Yasenya](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@Yasenya](https://root-forum.cern.ch/u/Yasenya)\
**Post date:** [April 4, 2022, 7:36am UTC](https://root-forum.cern.ch/t/creating-a-right-trapezoid-prism/49458/3 "2022-04-04T07:36:51Z")

</div>

@dastudillo It works perfectly, thank you very much.

However, If you don’t mind, I have an additional question concerning this shape:

I want to add this shape inside a container and later I will add other volumes as well. I am trying to use AddNode command as I did for other volumes, however It was unable to add this shape. I though I should transform this shape into a volume using :

```auto
TGeoManager::Volume(prisms,c, 2)
c->SetLineColor(5); 
container1->AddNode(c, 1);
top->AddNode(container1,1);
gGeoManager->GetVolume("container1")->SetVisibility(true);
gGeoManager->SetTopVisible();
gGeoManager->GetVolume("container1")->Draw();

```

where number 2 represents the medium Aluminium. But this idea did not work. How can I add this shape inside any container volume, using AddNode command, like it is the case for an ordinary box or tube ?

Thank you for your attention.

---

<div class="post-metadata">

**Author:** ![couet](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/couet/32/12037_2.png) [@couet](https://root-forum.cern.ch/u/couet)\
**Post date:** [April 4, 2022, 8:32am UTC](https://root-forum.cern.ch/t/creating-a-right-trapezoid-prism/49458/4 "2022-04-04T08:32:45Z")

</div>

May be @agheata can help with your last question.

---

<div class="post-metadata">

**Author:** ![agheata](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/agheata/32/37311_2.png) [@agheata](https://root-forum.cern.ch/u/agheata)\
**Post date:** [April 4, 2022, 9:36am UTC](https://root-forum.cern.ch/t/creating-a-right-trapezoid-prism/49458/5 "2022-04-04T09:36:49Z")

</div>

```cpp
TGeoArb8 *righ_prism_shape = new TGeoArb8("right_prism", 15, (Double_t*)verts);
TGeoVolume *right_prism_vol = new TGeoVolume("right_prism_vol", righ_prism_shape, some_medium_ptr);
container1->AddNode(right_prism_vol, 1);

```

---

<div class="post-metadata">

**Author:** ![Yasenya](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/y/b9bd4f/32.png) [@Yasenya](https://root-forum.cern.ch/u/Yasenya)\
**Post date:** [April 4, 2022, 3:06pm UTC](https://root-forum.cern.ch/t/creating-a-right-trapezoid-prism/49458/6 "2022-04-04T15:06:50Z")

</div>

@agheata Thank you very much, this code solved the problem.
