Hello,
I’d like to calculate intersection volume between 2 volumes: a tube and a box for a simple example.
In the following lines I create a tube and a box, and both insert them within a world (box overlapses tube on purpose). I want to calculate the volume of overlapping: for this simple example the overlapping volume is equal to box volume… To this end, I create a TGeoOverlap object. Then, I call SampleOverlap() method to estimate overlapping volume and it seems to calculate a volume which is equal to tube volume. However I expected the box’s volume.
Have I not understand something in TGeoOverlap or/and SampleOverlap() use ?
Thanks a lot
Julien
ROOT Version: ROOT 6.16/00
Platform: MacOs
Compiler: Clang
void test_inter() {
gSystem->Load("libGeom");
TGeoManager *geom = new TGeoManager("GeoManager", "Root_Geometry");
TGeoMaterial* vacuum = new TGeoMaterial("vacuum");
TGeoMedium * vide = new TGeoMedium("VIDE", 1, vacuum);
TGeoMedium * eau = new TGeoMedium("EAU", 1, vacuum);
TGeoMedium * air = new TGeoMedium("AIR", 1, vacuum);
// WORLD volume
Double_t r_min = 0.;
Double_t r_max = 400.;
Double_t z_size = 1400.;
TGeoVolume *world = geom -> MakeTube("World", vide, r_min, r_max, z_size / 2);
// tube volume
r_min = 0.;
r_max = 20.;
z_size = 100.;
TGeoVolume *tube = geom -> MakeTube("Tube", eau, r_min, r_max, z_size / 2);
// box volume
Double_t x_size = 10.0 ;
Double_t y_size = 10.0 ;
z_size = 10.0 ;
TGeoVolume *mesh = geom -> MakeBox("Mesh", air, x_size / 2, y_size / 2, z_size / 2);
Double_t vol_mesh = mesh->Capacity();
Double_t vol_tube = tube->Capacity();
cout << vol_mesh << " " << vol_tube << endl ;
TGeoTranslation *ID = new TGeoTranslation("id", 0., 0., 0.) ;
// volumes are inserted in world
world -> AddNode(tube, 0, ID);
world -> AddNode(mesh, 0, ID);
// TGeoOverlap definition
TGeoOverlap *overl = new TGeoOverlap ("Overl", tube, mesh, ID, ID, kTRUE, 0.00001) ;
overl -> SampleOverlap(1000000);
geom -> SetTopVolume(world);
geom -> CloseGeometry();
world -> SetVisContainers(kTRUE);
geom -> SetTopVisible(kFALSE);
//world -> Draw();
geom->Export("test_inter.root") ;
}