Geometry - Estimation of overlap volume between 2 volumes

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")         ;

    }

@agheata can you please take a look?

Thank you,
Oksana.

Dear Julien,
Indeed, you probably misunderstood the purpose of this method: it is not to compute the capacity of the overlapping region between two volumes, but just to draw random points in this region so that it becomes more visible. The class is normally used as utility by the overlap checker (geom->CheckOverlaps()) that will create it automatically. The value = Overlap : Overl ovlp=1e-05 that you get in the output is not the capacity of the overlap, but what you gave yourself to the constructor. The overlap checker estimates this value beforehand by sampling (it represents the maximum distance found between a point belonging to one shape with respect to the surface of the other).

Now, to actually estimate what you want you have to write a method doing the following:

  • generate N random points in the bounding box of the mother volume of the 2 shapes. Convert each point to the reference frame of each of the 2 shapes check if it is contained (TGeoShape::Contains). If the point is contained in both, then increment a Novlp counter.
  • The estimated capacity of the overlapping region is given by: Vbbox * Novlp/N, where Vbbox is the capacity of the mother volume bounding box. The error of this goes like 1/sqrt(Novlp)

Dear agheata,

I tried your solution based on Monte-Carlo calculation for my overlap volume estimation : I thank you, it works perfectly.

I had understood the Overlaps algorithm and maximum distance. Nevertheless, I come again to SampleOverlaps use: if I look SampleOverlaps definition in TGeoOverlap source code, I find this:

  224  marker->Draw("SAME");
  225  gPad->Modified();
  226  gPad->Update();
  227  Double_t capacity = fVolume1->GetShape()->Capacity();
  228  capacity *= Double_t(iovlp)/Double_t(npoints);
  229  Double_t err = 1./TMath::Sqrt(Double_t(iovlp));
  230  Info("SampleOverlap", "#Overlap %s has %g +/- %g [cm3]",
  231  GetName(), capacity, err*capacity);

I understand of these lines that overlapped capacity is estimated using MC method as you described (line below in TGeoOverlaps). Is the capacity estimated here not the overlap one?

Best regards,

Julien

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