"No medium" problem

Hello all,
I am currently working on a code I find online in order to create a PET tomography ring design with embedded photodetectors composed of Cherenkov radiators. I employed the following formula. However, I consistently get the error “Warning in TGeoManager::CheckGeometry: Volume “COMP” has no medium: assigned dummy medium and material” How can I fix this issue? I already created this volume as a composite shape made of addition and subtraction of several boxes made of Al, Si and cadmium tungstate. Thus, I thought that the medium is already defined. Any help would be greatly appreciated.

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

The code:

#include <TGeoManager.h>

#include < iostream>

#include< cmath>

using namespace std;

void photodetector ()

{

// gStyle->SetCanvasPreferGL(true);

gSystem->Load(“libGeom”);

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

//— define some materials

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 *Si = new TGeoMedium(“Si”,4, matSi);

//— make mixture lead glass

TGeoElementTable *table = gGeoManager->GetElementTable();

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

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

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

TGeoMixture *cadmiumt = new TGeoMixture(“cadmiumt”,5,7.9);

cadmiumt->AddElement(el1,0.177);

cadmiumt->AddElement(el2,0.313);

cadmiumt->AddElement(el3,0.510);

printf("___________________________________________________________\n"); printf(“Cadmium tungstate:\n”);

cadmiumt->Print();

TGeoMedium *mcadmiumt = new TGeoMedium(“cadmiumt”,5, cadmiumt);

//define the top container volume

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

top->SetLineColor(kMagenta);

geom->SetTopVolume(top);

top->SetVisibility(false);

// make detector

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

D->SetVisibility(false);

// make boxes

TGeoVolume *box1 = geom->MakeBox(“box1”,Al,4.5,0.6,0.6);

TGeoVolume *box2 = geom->MakeBox(“box2”, Vacuum, 4.5,0.45,0.45);

TGeoVolume *box3 = geom->MakeBox(“box3”, mcadmiumt, 4.5,0.45,0.45);

// SiPm Silicon

TGeoVolume *box4 = geom->MakeBox(“box4”, Si, 0.2,0.45,0.45);

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

t1->RegisterYourself();

//composition

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

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

comp->SetLineColor(5);

D->AddNode(comp, 1);

// create matrix

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

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

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

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

D->AddNode(comp,5,new TGeoTranslation(0.,6.0,0.));

D->AddNode(comp,6,new TGeoTranslation(0.,7.2,0.));

double z;

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

{

z= (1.2*i);

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

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

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

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

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

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

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

} //duplicate matrix

// make container ring

auto ring = geom->MakeTube(“ring”, Vacuum, 35, 49, 8.4);

// divide ring in sectors that will hold each detector

auto sector = ring->Divide(“Sector”, 2 , 24,0., 0.);

sector->AddNode(D, 1, new TGeoTranslation(36.8,-3.6,-3.6)); // Make sure the sector actually fits the detector

top->AddNode(ring, 1);

// close geometry

geom->CloseGeometry();

gGeoManager->GetMasterVolume()->Draw();

comp->SetLineColor(kBlue);

}

Okay thank you, as I am a new user I am newly learning these kinds of necessities. @Wile_E_Coyote Can you please help me with the issue I am having, I couldn’t find a proper solution to it.