Message: Re: Trouble with G4SubtractionSolid  bug? in CLHEP::HepRotation  Not Logged In (login) 
I believe that I have found a bug in the handling of compound rotations about the coordinate axes in CLHEP::HepRotation (== G4RotationMatrix). The details are below, but my question is this. Does GEANT4 have an official channel to communicate bugs to the CLHEP developers, or should I report this on my own, with a small test example?
On Sat, 15 Jan 2011 05:31:01 GMT, Michael H. Kelsey wrote: > I am having trouble constructing a specific G4SubtractionSolid: a flat > panel (scintillator veto) with a cylindrical hole drilled at an angle to > the surface. The attachment http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2011/01/15/13.2577267pentagonhole_wrong.eps shows the problem: The hole you see should be along the viewpoint (X) axis, but instead it is perpendicular to the angled yellow panel. To create the panel with a hole, I used:
G4Box* panel = new G4Box("Panel", scintThick/2., sidePanelWidth/2., midPanelHeight/2.); G4Tubs* pipe = new G4Tubs("PipeHole", 0., radius, thick/2., 0, 360*deg);
G4double phi = panelTransform.getRotation().phiX();
G4RotationMatrix holerot; holerot.rotateY(90*deg).rotateZ(phi);
G4ThreeVector holepos(0., holeY, holeZ);
G4VSolid* panelWithHole = new G4SubtractionSolid("PanelWithHole", panel, pipe, &holerot, holepos); The "holerot" construction should be clear: first rotateY(90*deg) is done, and second rotateZ(phi) is done). What I have discovered is that I get the correct result if I reverse those two rotations, that is,
G4RotationMatrix holerot; holerot.rotateZ(phi).rotateY(90*deg); Which says do the Z rotation first followed by the rotation about Y; see http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2011/01/15/13.3794283pentagonhole_right.eps . Now the hole doesn't have visible sides, and the adjacent panel now has a nice piece chipped out of it. If I generate my full detector, including the pipe coming through the hole, neither grid_test nor cylinder_test report any errors. The picture looks right (no overlapping colors), http://hypernews.slac.stanford.edu/HyperNews/geant4/get/AUX/2011/01/15/13.4340324pentagonpipe.eps . I believe this reflects a bug in CLHEP::HepRotation. Compound rotations should be applied by matrix left multiplication, that is R(1+2) = R2 * R1, for arbitrary rotation matrices 1 and 2. This is how the rotateX/Y/Z operations are documented in CLHEP/Vector/Rotation.h. My result above suggests that HepRotation has actually implemented the compounding by right multiplication; that is rotateX(), rotateY(), and rotateZ() are implemented as R' = R * rotateX, etc., instead of as R' = rotateX * R. I just checked this by explicit multiplication: left multiply shows up wrong, right multiply shows up correct. I know this isn't a GEANT4 issue. As I asked above, though, does GEANT4 have an "official" way to communicate such bugs back to CLHEP, or should I do so on my own?  Michael Kelsey

Inline Depth:  Outline Depth:  Add message: 
to: 