FindNormal in TGeoManager

Hi,

I try to use FindNormal() in TGeoMangager, but very often it returns a
surface normal that disagrees with my opinion. In such situations it is
usually something wrong with me, but I am not able to find out where I go wrong:

In the macro below, I first go from the center of a box straight down to the
boundary and compute the normal and get [0 0 -1] which I believe is
correct. Then I go from the same center to the same bottom boundary,
but now with an angle of 45 degrees (see red and green dots in the
attached file FindNormalTest.jpg). But this time I get the normal [1 0
0]. Now, if I change FindNormal() to FindNormalFast() I get [0 0 -1] as
expected. What is wrong?

Thanks,

Børge

{
gROOT->Reset(“a”);
gSystem->Load(“libGeom”);
TGeoManager *geom = new TGeoManager(“simple1”, “Simple geometry”);
TGeoMaterial *matVacuum = new TGeoMaterial(“Vacuum”, 0,0,0);
TGeoMedium *vacuum = new TGeoMedium(“Vacuum”,1, matVacuum);
TGeoVolume *top = geom->MakeBox(“TOP”, vacuum, 10, 10, 10);
TGeoVolume *slab = geom->MakeBox(“SLAB”, vacuum, 10, 10, 5);

top->AddNode(slab,1);
geom->SetTopVolume(top);
geom->CloseGeometry();
top->Draw();

Double_t Xdir[2] = {0,1};
for(Int_t i=0; i<2; i++) {
geom->SetCurrentPoint(0,0,0);
geom->SetCurrentDirection(Xdir[i],0,-1);
geom->FindNode();
geom->DrawCurrentPoint(1);
geom->FindNextBoundary();
geom->Step(kTRUE,kFALSE); //Go to boundary, but do not cross
geom->DrawCurrentPoint(2+i);
Double_t *norm = geom->FindNormal();
//Double_t *norm = geom->FindNormalFast();
Double_t *dir = geom->GetCurrentDirection();
cout << “Surface normal is [”<<norm[0]<<" “<<norm[1]<<” “<<norm[2]
<<”] for direction ["<<dir[0]<<" “<<dir[1]<<” “<<dir[2]<<”]"<<endl;
}
c1->GetView()->Front();
//c1->Print(“FindNormalTest.jpg”,“jpg”);
}

OUTPUT:
Surface normal is [0 0 -1] for direction [0 0 -1]
Surface normal is [1 0 0] for direction [1 0 -1]


Hi,

  1. The direction vector of the track is expected to be normalized by the user, e.g. nxnx+nyny+nz*nz = 1. This is not the case for your second try.

  2. There is a much better replacement now for FindNextBoundary() + Step() =
    FindNextBoundaryAndStep() that allows you to call FindNormalFast() afterwords. So: Initialize your point/correct direction, call FindNextBoundaryAndStep() then FindNormalFast()

Cheers,