Addnode utilization

Hello all,
I am a newbie to ROOT. I have been working on a code I found online for the construction of a photodetector design. The code is found below.

My question is about the “addnode” parts. In this configuration each box of alimunium has a side of 0.2 mm in y and z axis. However to create 5 boxes aligned vertically , commands such as " D->AddNode(comp,1,new TGeoTranslation(0.,.4,0.));" are used. And 0.4 mm increases are used for each node. Given that the sides are 0.2 mm, shouldn’t the distance between the nodes be 0.2 mm and the corresponding code "D->AddNode(comp,1,newTGeoTranslation(0.,.2,0.)); with 0.2 mm increases for each node? Thanks in advance.

_ROOT Version:
From tags/v6-24-06@v6-24-06 |
| With Apple clang version 13.0.0 (clang-1300.0.29.3)

#include “TGeoManager.h”

#include iostream>

#include cmath>

using namespace std;

void pet()


// gStyle->SetCanvasPreferGL(true);


TGeoManager *geom = new TGeoManager(“world”, “Simple geometry”);

//— define some materials

TGeoMaterial *matPb = new TGeoMaterial(“Pb”, 207.2, 82, 11.34);

TGeoMaterial *matVacuum = new TGeoMaterial(“Vacuum”, 0,0,0);

TGeoMaterial *matAl = new TGeoMaterial(“Al”, 26.98,13,2.7);

TGeoMaterial *matSi = new TGeoMaterial(“Si”, 28.0855,14,2.3290);

//— define some media

TGeoMedium *Vacuum = new TGeoMedium(“Vacuum”, 1, matVacuum);

TGeoMedium *Al = new TGeoMedium(“Al”,2, matAl);

TGeoMedium *Pb = new TGeoMedium(“Pb”,3, matPb);

TGeoMedium *Si = new TGeoMedium(“Si”,4, matSi);

//— make mixture lead glass

TGeoElementTable *table = gGeoManager->GetElementTable();

TGeoElement *el1 = table->GetElement(8);

TGeoElement *el2 = table->GetElement(14);

TGeoElement *el3 = table->GetElement(22);

TGeoElement *el4 = table->GetElement(33);

TGeoElement *el5 = table->GetElement(82);

TGeoMixture *glass = new TGeoMixture(“glass”,5,6.22);






printf("___________________________________________________________\n"); printf(“Lead glass:\n”);


TGeoMedium *mglass = new TGeoMedium(“glass”,5, glass);

//define the top container volume

TGeoVolume *top = geom->MakeBox(“TOP”,Vacuum, 110, 110, 110);




// make detector

TGeoVolume *D = geom->MakeBox(“D”, Vacuum, 100, 100, 100);


// make boxes

TGeoVolume *box1 = geom->MakeBox(“box1”,Al,1.5,0.2,0.2);

TGeoVolume *box2 = geom->MakeBox(“box2”, Vacuum, 1.5,0.15,0.15);

TGeoVolume *box3 = geom->MakeBox(“box3”, mglass, 1.5,0.15,0.15);

// SiPm Silicon

TGeoVolume *box4 = geom->MakeBox(“box4”, Si, 0.05,0.15,0.15);

TGeoTranslation *t1 = new TGeoTranslation(“t1”, 1.55,0,0);



TGeoCompositeShape *cs = new TGeoCompositeShape(“cs”,"((box1-box2)+box3)+box4:t1");

TGeoVolume *comp = new TGeoVolume(“COMP”, cs);


D->AddNode(comp, 1);

// create matrix

D->AddNode(comp,1,new TGeoTranslation(0.,.4,0.));

D->AddNode(comp,2,new TGeoTranslation(0.,.8,0.));

D->AddNode(comp,3,new TGeoTranslation(0.,1.2,0.));

D->AddNode(comp,4,new TGeoTranslation(0.,1.6,0.));

double z;

for ( int i=1; i<=4; i=1+i )


z= (0.4*i);
D->AddNode(comp,i,new TGeoTranslation(0.,0.,z));

D->AddNode(comp,i+3,new TGeoTranslation(0.,.4,z));

D->AddNode(comp,i+4,new TGeoTranslation(0.,.8,z));

D->AddNode(comp,i+5,new TGeoTranslation(0.,1.2,z));

D->AddNode(comp,i+6,new TGeoTranslation(0.,1.6,z));

} //duplicate matrix

top->AddNode(D,1,new TGeoTranslation(41.5,-0.8,-0.8));

TGeoRotation *r1 = new TGeoRotation(“r1”,180,0,0);

TGeoCombiTrans *c1 = new TGeoCombiTrans(-41.5,0.8,-0.8,r1);


// close geometry




I guess @agheata should know.

1 Like

Hi, the TGeoBBox constructor takes the half-size, so when you provide 0.2 means the total size on that axis is 0.4. So it is correct to increment by 0.4 in AddNode translations if you want boxes to be touching each other

Thank you so much, I am finally able to understand the general concept of creating this structure. If it isn’t too much work, can you also visit the following topic? I couldn’t managed to perform a ring design and it is very important for my thesis. I searched online similar topics, but wasn’t able to find a solution. I am not able to insert a link of the topic, as I am a new user, but I am including the title.Thanks in advance. @agheata

"Creating-multiple-copies-of-a-composite-shape "