Message: Re: erroneous hit position less SD volume center comparison with volume extent---need help! Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Note Re: erroneous hit position less SD volume center comparison with volume extent---need help!  

Keywords: volume center look-up hit position solid extent discrepancy
Forum: Event and Track Management
Re: Question erroneous hit position less SD volume center comparison with volume extent---need help! (Blair Smith)
Date: 15 Mar, 2006
From: Blair Smith <bmsmith@lsu.edu>

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

 touchHandle->GetHistory()->GetTopTransform().NetRotation();

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:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

 Add Message Add Message
to: "Re: erroneous hit position less SD volume center comparison with volume extent---need help! "

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]