|Message: Re: erroneous hit position less SD volume center comparison with volume extent---need help!||Not Logged In (login)|
Click on the Forum title, e.g. on the "Forums by Category" page, to read a sequence of postings to the Forum and its threads all in one page. If you are only interested in one thread or the thread following a specific posting, click the thread or the posting, which takes you to a smaller page, which contains only the part you are interested in and may be easier to navigate.
Messages are "chained" if there are only replies at the first level, i.e. 1/1.html, 1/1/1.html etc. In case of "chained" messages the message number is replaced by the icon and there is no indentation.
Inline: Display the subject line only or also the text of the posting(s); for the choice "All" the "Outline" choices are switched off.
|1||0||1||no text / full text of posting|
|2||1||All||text for level 1 only / text for All postings|
Outline: Choose the depth of the posting thread, successive toggle controls provide increasing detail.
|1||2||1||2 levels / 1 level (original posting)|
|2||3||2||3 levels / 2 levels|
|3||3||All||3 levels / all levels (all postings)|
OK, I think I realize my error.
When I compare the look-up center in global coordinates to the SD volume in the touchablke history it agrees with my hand calculations given my input geometry.
However, when I check to see if the hit is within the physical volume extent (half the extent in each coordinate direction) I was getting an error simply because I forgot to also rotate the volume's extent vector so that the effective G4Box volume ends up correctly aligned. To fix this I now use
to get the rotation of the top level volume that I am in, and apply this to a vector made up of the volume's extents.
Ammending my previous code to now read:
G4VPhysicalVolume* pixPhysVol = theTouchable->GetVolume(igd); G4LogicalVolume* pixLogical = pixPhysVol->GetLogicalVolume(); G4VSolid* pixelSolid = pixLogical->GetSolid(); G4VisExtent pixelExtent = pixelSolid->GetExtent(); G4TouchableHandle touchHandle = postStepPoint->GetTouchableHandle(); G4ThreeVector vec_origin(0.,0.,0.); G4ThreeVector pixCenter = touchHandle->GetHistory()->GetTopTransform().Inverse().TransformPoint(vec_origin);
G4double deltaX = pixelExtent.GetXmax() - pixelExtent.GetXmin(); G4double deltaY = pixelExtent.GetYmax() - pixelExtent.GetYmin(); G4double deltaZ = pixelExtent.GetZmax() - pixelExtent.GetZmin();
G4ThreeVector pixExt = G4ThreeVector(deltaX, deltaY, deltaZ); errorPos = G4ThreeVector(0.5*deltaX, 0.5*deltaY, 0.5*deltaZ); G4RotationMatrix rotPix = touchHandle->GetHistory()->GetTopTransform().NetRotation(); G4ThreeVector rotPixExt = rotPix*pixExt; rotPixExt = G4ThreeVector(fabs(rotPixExt.x()),fabs(rotPixExt.y()),fabs(rotPixExt.z())); G4ThreeVector posOffset = pixCenter - hitPos;
This seems to solve the problem. Here hitPos is just the given position of the hit, so now (pixCenter-hitPos) < 0.5*rotPixExt component-wise as I expect. The key was simply to rotate the extent vector because my G4Box volume at level igd is not a perfect cube, they are in general rectangular prism boxes, so rotation makes a difference!
By the way, I do not know how to conduct a similar test for non-rectangular box volumes, like cones or spheres (though a sphere would be easy by simply checking the radial extent). However, this entire exercise was conducted using simple box volumes merely so that I could trust the volume center global coordinate retrieval method. Now that I trust it I will not need this test in future.
|Inline Depth:||Outline Depth:||Add message:|